I want to maintain http request Cookie:ASP.NET_SessionId
- When user login to Application i can set Cookie:ASP.NET_SessionId
- When user logout the Cookie:ASP.NET_SessionId should not same as user login
Currently i am getting same Cookie:ASP.NET_SessionId on all pages and i want to generate Cookie:ASP.NET_SessionId on each login.
I did try on Global.asax.cs but nothing is working.
static List<string> sessions = new List<string>();
static object sessionLock = new object();
void Application_SessionStart()
{
lock (sessionLock) {
sessions.Add(Session.SessionID);
}
}
void Application_SessionEnd()
{
lock (sessionLock) {
sessions.Remove(Session.SessionID);
}
}
if (HttpContext.Current.Response.Cookies.Count > 0)
{
foreach (string s in HttpContext.Current.Response.Cookies.AllKeys)
{
if (s == FormsAuthentication.FormsCookieName || s.ToLower() == "asp.net_sessionid")
{
HttpContext.Current.Response.Cookies[s].Secure = HttpContext.Current.Request.IsSecureConnection;
}
}
}