Click here to Skip to main content
15,896,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two website with different domain.1 is www.example.com and 2nd is test.example.com both are contain same student details but when i login into 1st website i wanted to share that session details to 2nd website.
Posted
Comments
Sinisa Hajnal 31-Jan-15 6:20am    
What have you tried?

Session What you CAN do is post the data to your second site and put it in session variable in the second application.

Or you can use domain cookie if you're asking only and specifically about subdomain sites. Something like this
Response.Cookies("CookieName").Domain = ".example.com"

Remember that cookies have size limits though.

Learn more here[^]

If this helps please take time to accept the solution. Thank you.
 
Share this answer
 
If you have IIS infrastructure, you can share session state between servers. Look here: http://dotnetcodr.com/2013/07/01/web-farms-in-net-and-iis-part-5-session-state-management/[^].

But I am not sure, this is what you need. It looks like you need SSO (single sign-on). There are several implementations of it, so you should look around. Just as idea:
Enterprise Single Sign-On[^]
Single Sign On (SSO) for cross-domain ASP.NET applications: Part-II - The implementation[^]
 
Share this answer
 
Comments
[no name] 1-Feb-15 1:57am    
Hai,

I am used this below code i get the current session id.but how to pass the user login information to another subdomain.

using System.Web.SessionState;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserId"] == null) // Is Shared SessionState Available?
{
string sessionId = this.Session.SessionID;
// The SessionId From Source Website.

SessionIDManager manager = new SessionIDManager();
bool isRedirected; // Get true if cookieless=true and you redirected to the current page.
bool isNewSession; // Get true if a new "ASP.NET_SessionId" cookie will be created.
manager.SaveSessionID(Context, sessionId, out isRedirected, out isNewSession);
// Change sessionId in httpResponse of the current Context

Session["Temp"] = "Some useless data.";
// this operation is neccesary because sessionId read from Request and write to Response

Response.Redirect(Request.Path, true);
// Now redirect to current page to check if shared SessionState is available
}
else
{
// Do something after sharing the sessionStates
}
}
Zoltán Zörgő 1-Feb-15 3:03am    
Ok, and have you set up the session database and changed IIS configuration about session state on all those servers/subdomains?
[no name] 1-Feb-15 3:26am    
i can't get u..i done this C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe -S . -E -ssadd -sstype c ASPState.
created a ASPState database in my db
Zoltán Zörgő 1-Feb-15 3:31am    
What does it mean "you can't"... that is no error message..
[no name] 1-Feb-15 3:43am    
i get the current session id and its saved into ASPstate database.when i clicked into another subdomain i wanted to send username and password.but its not working.can u give some example for passing the session id for another domain with the username and password for current section.
You can do it in two alternate ways

First: Store session value in cookie and retrieve in your sub domain

Second: Pass query string to your sub domain and use it as session there

Suppose your sub domain is test.domain.com the pass query from domain.com like this

test.domain.com?query=XXXXX and in test.domain.com on page load event

Session["abc"]=Request.quesryString["query"];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900