Share via


Maintain Session State across different Applications

Question

Friday, April 17, 2009 3:28 AM

Dear All,

I want to know whether we can share login information stored in  session variables between 2 different web applications that are present on the same web server.  Basically what I want to do is that user logs in application A and then  I save his login name and password in session variables lets say

Session["username]="sam"
Session["password"]="password"

 Now i want to pass these session variables to a different web application B. and on Page load of web application B I want to retrieve these Session variables. Ideally I want to solve this by using SQL Server 2005 database if possible.  A simple working example would be greatly appreciated.

 cheers,
Sam Solomon

All replies (8)

Saturday, April 18, 2009 6:59 AM ✅Answered

Dear Sir,

 

Thanks for your reply. But I am looking for a SQL Server 2005 solution. I am interested to know how we can handle it using a database.

 

cheers,

Sam Solomon

 

 

Well you just need to have both apps pointing at a database using the same connection string, then both apps will be able to see the same data.

There is another option if you just want to share login authentication tickets between apps - you can use something called SSO (Single Sign-On) which is possible by following a tutorial like this:


Tuesday, April 21, 2009 11:50 PM ✅Answered

Hi,

Please check the following links:

How to share Session variables across Domains
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6245
http://blogs.msdn.com/toddca/archive/2007/01/25/sharing-asp-net-session-state-across-applications.aspx

Sharing Session Across Applications
http://www.codeproject.com/KB/session/sharedsession.aspx

How to share Session variables across Domains
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6245

help with sharing session across applications
http://forums.asp.net/p/1253375/2322764.aspx#2322764
http://forums.asp.net/p/1234883/2238654.aspx#2238654
http://forums.asp.net/p/1327172/2652923.aspx#2652923
http://forums.asp.net/p/1139717/1830350.aspx#1830350

How to Share Session/Application State Across Different ASP.NET Web Applications
http://www.asp101.com/articles/jayram/sharestate/default.asp

How to Share Session State Between Classic ASP and ASP.NET
http://msdn.microsoft.com/en-us/library/aa479313.aspx

Forms Authentication Across Applications 
http://msdn.microsoft.com/en-us/library/eb0zx8fc(VS.80).aspx

If you have anything unclear, please feel free to let me know directly.


Friday, April 17, 2009 5:24 AM

 I dont think you can share this information between apps directly.

You can store the information in a database yourself and then pass an auth ticket id that references it so that you can pull the information out the database in a different app.


Friday, April 17, 2009 5:40 AM

Dear Sir,

Thank you very much for your reply. I would appreciate if you can show me a working example.

 

cheers,

Sam Solomon


Friday, April 17, 2009 6:36 AM

 inyour web.config file

<appSettings>
    <add key="ApplicationName" value="SharedWeb"/>
</appSettings>
 http://www.asp101.com/articles/jayram/sharestate/default.asp 
http://www.codeproject.com/KB/session/sharedsession.aspx 
Regards
Asif
If my post is helpful for you, mark it as "ANSWER". It is useful for other users. 

 


Friday, April 17, 2009 7:28 AM

Dear Sir,

 

Thanks for your reply. But I am looking for a SQL Server 2005 solution. I am interested to know how we can handle it using a database.

 

cheers,

Sam Solomon


Saturday, April 18, 2009 11:18 PM

You can't share session objects between applications.

If you use forms authentication cookies, then you can use this in multiple sites so long as each web site had the same machine key and you used a common cookie domain.

 Storing user credentials in the session is a bad practice - if the session gets hijecked the hacker has credentials on the application.


Wednesday, April 22, 2009 1:50 AM

It is not possible to share session data between websites.  What you can do is either work from the same database, then each website will have access to the same data.  Alternatively you could pass the data between websites using the Request.QueryString class.