Changing expiry on ASP.NET's Session State cookie

Posted by Charlie Somerville on Stack Overflow See other posts from Stack Overflow or by Charlie Somerville
Published on 2010-06-09T08:40:02Z Indexed on 2010/06/09 8:52 UTC
Read the original article Hit count: 282

Filed under:
|
|
|
|

I'm using ASP.NET Session State to keep track of logged in users on my site.

However, one problem I'm running into is that by default ASP.NET session cookies are set to expire when the browser closes.

I've tried setting my own ASP.NET_SessionId cookie and modifying the cookie's expiry using something similar to the following code:

Response.Cookies["ASP.NET_SessionId"].Expires = DateTime.Now.AddMonths(1);

None of these approaches work, they all set a second cookie with the same name.

Is there a way of changing the session cookie's expiry?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET