Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a new browser window with a new session ID in ASP.NET

I need to open a second browser window or tab, but it must have a different session ID.

Opening the new browser window from an ASP.NET page is easy, but then it shares the same cookie and thus session ID with the original.

How can I do this?

like image 793
Daniel Brink Avatar asked Apr 15 '10 12:04

Daniel Brink


People also ask

Does opening a new tab create a new session?

1 Answer. Show activity on this post. Opening a new tab doesn't start a new session if the same site is already open in the same browser. The browser tries to use the existing session.

How is session ID stored in browser?

A session ID is a unique number that a Web site's server assigns a specific user for the duration of that user's visit (session). The session ID can be stored as a cookie, form field, or URL (Uniform Resource Locator). Some Web servers generate session IDs by simply incrementing static numbers.

Can session ID be reused?

By default, ASP.NET allows you to reuse a session identifier. For example, if you make a request and your query string contains an expired session, ASP.NET creates a new session and uses that session ID.

How is ASP.NET session ID generated?

Remarks. The SessionID property is used to uniquely identify a browser with session data on the server. The SessionID value is randomly generated by ASP.NET and stored in a non-expiring session cookie in the browser. The SessionID value is then sent in a cookie with each request to the ASP.NET application.


2 Answers

In IE you have to use File - New Session or there is a registry key you can set for tabs / sessions. Your tabs will change color showing you which session you are using.

like image 26
James Westgate Avatar answered Nov 15 '22 06:11

James Westgate


This is a browser limitation - browsers instances share cookie data (including session cookie) when they are running, so this is not possible with your standard browser.

If you have an option of running different browsers (IE and Firefox, for instance) they do not share cookies and will have different sessions.

Edit:

If you have control over IIS host headers and DNS in your environment, you may be able to use many different domain names - one per session.

The browser will treat each domain name as a different server and different cookies (and therefore sessions) will be created.

like image 85
Oded Avatar answered Nov 15 '22 04:11

Oded