Is in-process the only way classic ASP can store session state?

I know this is a simple question, but I can’t get it out of Google noise. I know that .NET can use the session state service or SQL database to return its session state, but I don’t know if ASP offers any parameters outside the process to store them. Does it have any data, or am I delaying the loss of session variables in ASP applications when the load balanced server is down?

+6
session asp-classic
source share
2 answers

Yes, only in memory

From MSDN Full article

ASP implementation

A native ASP session can only store session data in memory. To store session data on SQL Server, a Microsoft® Visual Basic® 6.0 COM custom object is written to control session state instead of using its own session object. This COM object will be created at the beginning of each web request and will reload session data from SQL Server. When the ASP script is completed, this object will be completed, and the session state will be saved on SQL Server.

The main purpose of the Visual Studio 6 COM object is to provide access to internal Microsoft® Internet Information Server objects. The Visual Basic 6.0 Session COM object uses the SessionSmility class for mySession to store session state and the SessionPersistence SessionUtility class to load and save session data using SQL Server. The mySession and SessionPersistence classes are displayed as COM objects using the regasm.exe utility. The regasm.exe utility can register and create a type library for the COM client to use Framework classes.

Session state information is reloaded during the construction of the object. The constructor (class_initialize) will first extract the session cookie, session timeout (SessionTimeOut), and database connection string (SessionDSN) from the Application object and create an instance of the mySession class to store session data. Then the designer will try to reload the session data from SQL Server with this cookie. If SQL Server does not have session information or the session has expired, a new cookie will be issued. If the SQL Sever returns with session state data, the session state will be stored in the mySession object.

+4
source share

Nothing is built in there, although ASP Classic is pretty easy to create your own session management system. The simplest form is a table in db, as shown below:

SessionID int PK, Field Text, Value Text, DateTime Expires

Come up with some kind of CSV encoder / decoder for fields and values ​​and fill out the collection on every page. Then save it after completing the page and updating the expiration time. Then simply ask the cookie to track the session identifier or pass it in the query string.

+4
source share

All Articles