Session Expiration in ASP.NET

S

Snig

Hi guys

How can I make the session in an ASP.NET application so that it NEVER
EXPIRES ?

thanks
 
P

Paul Glavich [MVP ASP.NET]

Store your session data in the database.

Surely you would not want your session to hang around longer than one day,
and in that case just set the <sessionState timeout="..." number of minutes
to however many you need for the day (eg. 8 * 60 for 8 hour day). Its a long
time to hold onto data though, especially if using in memory session store,
hence why I suggested the database. Store it there, get it when you need it.
 
S

Snig

Thanks Paul.
But, is there any way to configure it is such a way that the session is
stored in memory (InProc) and still it never expires ?
 
J

Juan T. Llibre

Given that Inproc sessionState management implies that the
ASP.NET worker process *will* recycle every so often,
there's no way to configure it so that a session never expires.

Sessions *will* expire when the worker process recycles,
if you're using InProc sessionState management.
 
H

Hans Kesting

Snig said:
Hi guys

How can I make the session in an ASP.NET application so that it NEVER
EXPIRES ?

thanks

I don't think you want that. If a user opens an other instance of his
browser, he gets a new session. If a session never expires, then data
from that session would hang around (=take up precious memory)
"forever". There is no way to go "back" to such an abandoned session.
The session doesn't automatically vanish when the user "navigates away"
or "closes his browser".

What you might want is a way to keep the session alive as long as that
user displays a page of your site. You could do that by refreshing that
page often enough (automatically: see <meta http-equiv=refresh>) to beat
the session timeout. Maybe you could refresh a special page that is
displayed in an iframe in some corner of your screen, if you don't want
to refresh the entire screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top