Managing Session State using aSMS, Part 4By Sessionmgmt@hotmail.com
In IIS Session Starts automatically when the users hit the first web page, usually
default.asp. In aSMS developers have the flexibility of starting the
session in any page from where they want to use session variables.
aSMS does not use IIS’s Session management. It uses it’s internal session management tool. Developers can disable the IIS Session State from MMC there by conserving lot of resources.
How to Start a Session
To start a Session, a developer must first create an instance of the aSMS Session object. This is done by calling the
Server.CreateObject() method, and passing it
Session.Management as the ProgId:
Once created, session can be started using the
How to End a Session
To end a session
SessionEnd() method can be used.
How to Check Session
aSMS allows the developers to check for the session in any page by just calling
CheckSession() method. This method checks whether the user is still in
session or timed out.
As a general rule of thumb this method has to be called in all the pages where session variables are used. This gives more flexibility to the developers and also resources can be conserved in other pages where session variables are not used.
How to Assign Session Variables
Session variables can be assigned by using
SetSession() method requires two arguments, one is name of the session
variable and other is the value.
In aSMS standard edition, developers can use the predefined variable names in LDAP. LDAP contains more than 150 variable names defined with data types as int, float, date, image, array etc. Developers can select the appropriate variable names and use them.
For e.g. some of the commonly used Session variable names and their corresponding LDAP variable names with their type
FirstName – givenName (string)
LastName – sn (string)
EmailAddress – mail (string)
Password – userPassword (string)
State – accountStatus (int)
For the complete listing of LDAP variable names Click Here.
Session variables can be assigned as:
How to retrieve the Session Variables
Session variables can be retrieved by using
GetSession() requires the session variable name passed as argument.
By this approach the session variables can be easily shared across different webservers in the Web farm without losing the data. As mentioned earlier LDAP is optimized for fast single read and write operations, so storing the session variables in LDAP wont harm the performance of the web server.
Migrating a current web site to use aSMS
For Migrating a current web site to aSMS check Migration/Deployment Page.
In this paper, we've discussed state management in a Web farm where two or more servers are used to host a single site. We've looked at several possible approaches to managing session state, including building stateless applications, storing session state on the client, using session-aware load-balancing, and storing session state on a central computer using asp Session Management Server..