Session Timeout problem

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
 
G

Guest

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
 
G

Greg9Strat

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...
 
J

Juan T. Llibre

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.

..
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top