Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Sharing session state over multiple ASP.NET applications

0.00/5 (No votes)
11 Sep 2003 1  
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.

Sample Image - Sharing_session_state.jpg

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here