g_b
g_b

Reputation: 12438

How does ASP.NET track session in multiple browsers/tabs?

How does ASP.NET web application track session in multiple browsers/tabs? For example, if I am logged on to some site, when I open a new instance of browser, it knows (or assumes) that I am still the same user therefore, it is the same session and still uses my credentials when I access the site in the new browser instance. But when I start new session in IE (in file menu), it uses a new session.

How is this done b ASP.NET and what does open a new session in IE actually does (I mean internally, I know that it will start a new session)? And is it the same for WebForms and ASP.NET MVC?

Upvotes: 2

Views: 4588

Answers (2)

user247702
user247702

Reputation: 24212

As mentioned in the comments, ASP.NET tracks your session with a session cookie.

According to this post on IEBlog, the new window will not share session cookies with the existing window, when you go through File -> New session. That's why you won't be logged on in the new window.

The blog explains some more what session merging is, if you're interested.

Upvotes: 3

RemarkLima
RemarkLima

Reputation: 12037

I'd never seen the "New Session" open in IE!

Your session is essentially an ID between the server and your browser (try it, response.write('Session.SessionID');) - this ID I held by the server for the session until timeout (usually 20 mins) and if you're using session cookies, then the cookie data is stored in server memory under that ID rather than persistent cookies, which are stored as text files local to the browser and sent to the server on request.

For ASP.net authentication, there is an AUTH cookie, this can be persistent - you want the login to remain even in a new browsing session - or not and will require login each session.

http://support.microsoft.com/kb/910443

To the question, this session ID is persisted across all tabs and browsing instances in IE unless you start a new session, which will have a different session ID for the server, hence new session details etc...

Upvotes: 2

Related Questions