Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Everyone,

In one of our application we are facing below issue related SessionId.
SessionId value in cookie (Request & Response body) are not regenerating new values once user logoff from application and logins back (I mean signing off from application without closing browser and singing in back). Its maintaining earlier values, instead of generating new values.

But if close browser it's generating new values. But we wanted to generate new SessionId values every time user logoff from application and logins back.

Much appreciate your help.

What I have tried:

We tried to clear cookie values in Logout handler
and Added expiration date to cookies like as
Response.Cookies["SessionID"].Expires = DateTime.Now.AddDays(-1);
But even after making these changes also we are not getting new sessionid value after logout and login.
Updated 8-Sep-19 3:13am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You should work with the Session object itself for this scenario.

Session.Clear() will clear all values attached to the current session. So if you are using Session to store a bunch of things related to User Login and such this remove them all. The SessionID will remain the same.

Session.Abandon() will kill the user session and also trigger the Session_End event. The Next request should also have a new SessionID
Ramesh0809 10-Sep-19 10:50am
Thanks you MadMyche. Actually our application is vast application (it has C++, classic asp and modern asp). I tried by clearing and Abandoned session. But some where in pipeline it's injecting same values again (I think because of classic asp but not sure).
But getting same ASP.NET_SessionId on re-login.
MadMyche 10-Sep-19 12:30pm
Classic ASP and ASP.Net are completely separate applications and each will have it's own Session- the process to clear/abandon would need to be done within both applications

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100