I have two websites with domains www.example.com and www.test.example.com both contain same student details. I want to share session between the two domains.Is it possible?
Asked
Active
Viewed 1,867 times
2
-
1possible duplicate of [How can I share a session across multiple subdomains in ASP.NET?](http://stackoverflow.com/questions/273732/how-can-i-share-a-session-across-multiple-subdomains-in-asp-net) – Mahesh Feb 03 '15 at 10:21
-
Already i have done the given link information.now its worked on my localhost but didn't worked in my domain.its showing a null value in session state for other domain. – Rajeesh Menoth Feb 03 '15 at 10:51
-
Locally its working fine but in server its not working – Rajeesh Menoth Feb 11 '15 at 04:58
-
you need to use sql state server session for this. – Manish Sharma Feb 19 '15 at 05:34
1 Answers
1
Use following method:
void MasterPage_Unload(object sender, EventArgs e)
{
///ASP.NET uses one cookie per subdomain/domain,
///we need one cookie for _all_ subdomains.
if (Context.Response.Cookies["ASP.NET_SessionId"] == null)
return;
var sessionCookie = new HttpCookie("ASP.NET_SessionId", Context.Session.SessionID);
sessionCookie.Domain = ".yourdomain.com" ;
Context.Response.SetCookie(sessionCookie);
}

Vishal
- 171
- 7
-
Thanks, but how to get this sessioncookie in another sub domain. – Rajeesh Menoth Feb 03 '15 at 10:48
-
I assume your subdomains map to the same application. If not then you can try one of the following, 1. SQL Server based Session storage 2. HttpModule to intercept and manipulate request at IIS – Vishal Feb 03 '15 at 10:54
-
Yes,still am using Sql server based session storage.how to pass the session state into other domain?.in my main domain i am using dynamic link so i can't use a Request.query string in other domain. – Rajeesh Menoth Feb 03 '15 at 10:58
-
http://www.codeproject.com/Articles/114484/Single-Sign-On-SSO-for-cross-domain-ASP-NET-appl – SilentTremor Feb 03 '15 at 11:07
-
I have two websites.I have uploaded the both website in given subdomain 1)test.example.com 2)run.example.com Locally its working fine but in server its not working.I wanted to share session between this application.using sql server as session mode.I done those activity based on given websites. http://www.codeproject.com/Tips/576989/Sharing-ASP-NET-Web-Applications-Session-State – Rajeesh Menoth Feb 11 '15 at 04:54
-
Now its working fine but one problem occurred.It was session shared in same domain because i put my another domain web app into same domain inside a sub folder with different port id.i wanted to share those details into another domain also. – Rajeesh Menoth Feb 12 '15 at 11:04