views:

1360

answers:

4

I need to renew my old session if the session timeout exceeds the default 20 mins. Is there any session renew concepts in ASP.net?

+1  A: 

One way to do this would be to write a JS function that fires at some interval. This function would make an asynchronous call (AJAX) to the server to keep the session alive. This way session will not timeout. This is one way that I am aware of and have seen used.

MK_Dev
+1  A: 

If you're renewing the session after it expires and when that one expires you'll renew it what you're really doing is not having it expire at all.

Why not just extend the session period beyond the 20 minutes in the first place? Is it conditional?

annakata
+1  A: 

Not really. At least, not post-expire.

The most common, that I've seen, is to send an Ajax "PING" request periodically. Just something to access the server and restart the timeout count for the session.

Jeff wrote about this a while back.

Jonathan Lonowski
+2  A: 

I had a similar issue a little while ago and found this article very helpful - at least in overcoming part of the problem.

I also added the following line into the defribulator page to prevent caching and it works fine for us.

<%@ OutputCache Location="None" VaryByParam="None" %>

Basically it performs an invisible postback (renewing the session) just before it is about to expire - we actually do it a little earlier than that.

Hope this helps but i can dig out some of the code I used if you want to have a look.

DilbertDave