Click here to Skip to main content
15,888,270 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to override the 'ASP.NET_SessionId' session cookies path value.
Path value is comming '/'
I want to set like '/Test'

What I have tried:

I have tried below code in Application_PreRequestHandlerExecute event of globel.aspx page. I have also searched in google.

var sessionState = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection;
var cookieName = sessionState != null && !string.IsNullOrEmpty(sessionState.CookieName)
? sessionState.CookieName
: "ASP.NET_SessionId";

var timeout = sessionState != null
? sessionState.Timeout
: TimeSpan.FromMinutes(20);

/// Ensure ASP.NET Session Cookies are accessible throughout the subdomains.
if (Request.Cookies[cookieName] != null && Session != null && Session.SessionID != null)
{
Response.Cookies[cookieName].Value = Session.SessionID;
Response.Cookies[cookieName].Path = Request.ApplicationPath;
Response.Cookies[cookieName].Expires = DateTime.Now.Add(timeout);
}
Posted
Comments
ZurdoDev 21-Jul-16 8:12am    
Why?
Member 13966795 31-Aug-18 1:50am    
i am also searching for this only

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