Session Timeout problem

  • Thread starter Thread starter metsie
  • Start date Start date
M

metsie

Hi all,

How can I set the session TimeOut from inside the Code? Also is there a
way to make the session variables Expires after a number of minutes of
inactivity. i.e. I want to make the session variables expires after the
user stays inactive for 20 minutes. I am using ASP.net 2.

Thanks in advance
 
20 minutes is the default session time out and it is set in the
configuration. You could code your own session timeout behaviour in
application_beginrequest (in global.asax) by holding time of last post in the
session, then one next request for the session, if that var is more than 20
minutes ago, cal Session.Clear or Session.Abandon (abandon destorys the whole
session and generates a new sessionid)

HTH

Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com
 
I don't know that you can dynamically set the session TimeOut value for
each session - that is a machine.config or web.config variable...

Am I to understand you correctly that you want to be able to destroy
the session variables after the TimeOut period passes, but keep the
session alive?

Thanks for clarification...
 
re:
I don't know that you can dynamically set the session TimeOut value for
each session - that is a machine.config or web.config variable...

You can...

Sub Page_Load(Sender As Object, E As EventArgs)
Session.Timeout = 30
End Sub

That will set the session timeout to 30 minutes, even if it's set to 20 minutes in web.config.

..



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Back
Top