Enumerating
Session Management Techniques
Before we proceed, let us see what all session management
techniques are present in the ASP.NET framework.
·
In-Proc.
·
SQLServer.
·
StateServer.
How to configure Sessions
To configure the session management we need to specify the
settings in the
web.config
file. Typical settings inweb.config
looks like:<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="Data Source=.\SQLEXPRESS;Trusted_Connection=Yes;"
cookieless="false"
timeout="100"/>
Let us see what each of these attributes mean.
Mode
|
This specifies the type of session
management we want to use. it could be
InProc ,SQLServer , and StateServer |
stateConnectionString
|
If we use
StateServer as session management technique then this specifies the
location of the server that is handling the session data. |
sqlConnectionString
|
If we use
SQLServer as session management technique then this specifies the
databaseconnectionstring that will store the session data. |
cookieless
|
This specifies whether we will be
using
cookies to identify
sessions or we want session info appended in URL. It could be true or false . |
Timeout
|
This specifies the time for which
the session should be active. after this much time of inactivity the session
will expire.
|
Hi,
session object is mainly used to store the data and pass it from one page to
another page in your applications.
syntax to use sessions
session["username"]=txtusername.Text;
To retrive the value in the session: string username=convert.tostring(session["username"]);
U can store a single variable or objects like dataset,datatable, array etc also in the sessions.
Once u close u r application, u r session data will be lost.
u have following types of session management in asp.net which u can define in your web.config file
session mode="inproc"...means the session will be stored on the webserver within u r application
session mode="outproc"....means session will be stored on the server outside u r application
session mode="stateserver"...means session will be stored in a temporary memory in the database
session mode="sqlserver"...means session will be stored in the databsae permanently.
syntax to use sessions
session["username"]=txtusername.Text;
To retrive the value in the session: string username=convert.tostring(session["username"]);
U can store a single variable or objects like dataset,datatable, array etc also in the sessions.
Once u close u r application, u r session data will be lost.
u have following types of session management in asp.net which u can define in your web.config file
session mode="inproc"...means the session will be stored on the webserver within u r application
session mode="outproc"....means session will be stored on the server outside u r application
session mode="stateserver"...means session will be stored in a temporary memory in the database
session mode="sqlserver"...means session will be stored in the databsae permanently.
No comments:
Post a Comment