Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ensure that session state is NOT shared between applications hosted on the same server

My question is the opposite of the following
Sharing session state between 2 ASP.NET applications using SQL Server and How to maintain the same session id across multiple web applications in ASP.NET.

Our application uses state server to store session info and we often want to host several versions of the same application on the same web server.

At the moment, because the ASP.NET_SessionId cookie is not stored against any path, if I got to http://donkey.com/app1 and start a new session and then, in the same browser session, go to http://donkey.com/app2, I inherit the session ID (and thus session state) from app1.

Is there a way to cajole ASP.Net to set the path when it stores the session ID cookie and thus break this unwanted sharing of session state?

like image 332
Chris Fewtrell Avatar asked Dec 28 '22 23:12

Chris Fewtrell


1 Answers

You'll have to use different cookieName for each web application in web.config.

The default is "ASP.NET_SessionId".

You can also programmatically set it. Check this post.

like image 100
Bala R Avatar answered Feb 16 '23 00:02

Bala R