Click here to Skip to main content
15,867,568 members
Articles / Web Development / ASP.NET
Article

Sharing session state over multiple ASP.NET applications

Rate me:
Please Sign up or sign in to vote.
1.03/5 (24 votes)
11 Sep 2003 97.7K   1.4K   25   8
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


Written By
Web Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionSession does not work among two application sharing two diffrent IPs and Header value. any solutuion ? Pin
MyRitu13-Apr-09 20:35
MyRitu13-Apr-09 20:35 
GeneralDetail Pin
aqua19822-Jun-08 0:44
aqua19822-Jun-08 0:44 
Can u give me cmplete detail of this code piece.
GeneralExtra Information need on this Pin
sacp.net16-Aug-05 18:34
sacp.net16-Aug-05 18:34 
GeneralThanks! Pin
shroomy11-Jun-04 6:35
shroomy11-Jun-04 6:35 
QuestionHow can I to know my Web Application's AppName Pin
cbriano1-Nov-03 8:09
cbriano1-Nov-03 8:09 
AnswerRe: How can I to know my Web Application's AppName Pin
.NET Follower20-Jan-04 23:11
.NET Follower20-Jan-04 23:11 
GeneralNot exactly safe and reliable Pin
Anonymously12-Sep-03 15:15
Anonymously12-Sep-03 15:15 
GeneralDoesn't explain Pin
dog_spawn12-Sep-03 13:11
dog_spawn12-Sep-03 13:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.