Click here to Skip to main content
14,239,281 members

Sharing session state over multiple ASP.NET applications

Rate this:
1.03 (24 votes)
Please Sign up or sign in to vote.
1.03 (24 votes)
11 Sep 2003
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.

<!--<span class="code-comment"> 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".
--></span>
<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

Share

About the Author

SampoSoft
Web Developer
Italy Italy
No Biography provided

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
memberMyRitu13-Apr-09 20:35 
GeneralDetail Pin
aqua19822-Jun-08 0:44
memberaqua19822-Jun-08 0:44 
GeneralExtra Information need on this Pin
sacp.net16-Aug-05 18:34
membersacp.net16-Aug-05 18:34 
GeneralThanks! Pin
shroomy11-Jun-04 6:35
membershroomy11-Jun-04 6:35 
QuestionHow can I to know my Web Application's AppName Pin
cbriano1-Nov-03 8:09
membercbriano1-Nov-03 8:09 
AnswerRe: How can I to know my Web Application's AppName Pin
.NET Follower20-Jan-04 23:11
member.NET Follower20-Jan-04 23:11 
GeneralNot exactly safe and reliable Pin
Anonymously12-Sep-03 15:15
memberAnonymously12-Sep-03 15:15 
GeneralDoesn't explain Pin
dog_spawn12-Sep-03 13:11
memberdog_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.

Article
Posted 11 Sep 2003

Stats

90.8K views
1.4K downloads
25 bookmarked