简体   繁体   中英

asp.net sessionId to restore session object

In my ASP.NET application, at some point I have to redirect to another domain to do user authentication and if success that domain will redirect back to my domain.

for example:

my domain:    www.domainA.com
other domain: wwww.domainB.com
flow: domainA.com (goes to)-> domainB.com (goes to)-> domainA.com

So what I would like to do is to store the session object in domainA before going to domainB and then restore the session object when it comes back to domainA.com.(not sure if that's even possible)

What I've told about is that asp.net by using sessionID will create a cookie called "ASP.NET_SessionId" so when it comes back to my domain it will be used to restore the session.(again not sure if that's true)

If the above statement is true, how can I restore the session object?

If it's not true then how can I store my session object in domainA.com until it goes through the authentication flow at domainB.com and then comes back to domainA.com?

PS: When it comes back to domainA.com the cookie is still there with the same value.

Session variables are stored on server. A new session variable is created for each new user. The server stores a user's session with a unique session ID, so that every user's Session can be uniquely identified.

The SessionID is combination of client's details such as User's IP, browser used, browser version, OS, OS version etc.

We can get this sessionID using HttpCookie("ASP.NET_SessionId", "") . Which you can save in a session object before you redirect to another page. And if user authentication is successful, you can pass a boolean value from 'domainB' page to 'domainA' page. And if boolean value is true then restore the session else not.

For more information on usage of SessionID : Refer this page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM