Using Session variable in ASP.NET page

  • Thread starter Thread starter Stimp
  • Start date Start date
S

Stimp

When a user logs into my site, I create a cookie with their UserID, but
I wish to also create a Session variable to track their "UserType".

I do this as follows:

Session("UserType") = "admin"

(or whatever value I give the usertype)

I use this session variable to output a user-specific menu.

This works fine, until I pause using the page for about 5 minutes, then
when I go back to the page, the session variable has disappeared
(expired).

Is this expiry timeout something I need to set on the server, or is
there a better approach I should take to this problem using ASP.NET?

Thanks.
 
Hi,

If you are looking for session expiry event, you have to do this on the
server. This event would be available in Global.aspx.cs file.

Cheers,
Kris
 
Hi,

If you are looking for session expiry event, you have to do this on the
server. This event would be available in Global.aspx.cs file.

Cheers,
Kris

actually I think I've found it... I can change the timeout flag in the
sessionState tag in web.config
 
Back
Top