Sharing session state over multiple ASP.NET applications






1.03/5 (21 votes)
Sep 12, 2003

98582

1383
This is an article that explains how to share session variables over multiple applications.
Introduction
I have modified the SQL script that create the SQL Server Database for storing the ASP.NET session state.
Using the code
In web.config you must change the sessionState from "InProc" to "SQLServer" and specify the correct SQL connection string.
<!-- SESSION STATE SETTINGS By default ASP.NET uses cookies to identify which requests belong to a particular session. If cookies are not available, a session can be tracked by adding a session identifier to the URL. To disable cookies, set sessionState cookieless="true". --> <sessionState mode="SQLServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20" />
I have added a table named ASPStateApplications
that can be used to set the applications that share the session state.