Thursday, March 22, 2012

session variables

Hi,

I am having a strange thing happen.. my session variables are expiring after only a few minutes, even though I have set them to expire in 30 minutes in my web.config and in my IIS.

The site is working using forms-based authentication and the auth cookie seems to last.. its just the session variables that disappear quickly!

any ideas?

thanks, rich.Just to check,

The timeout for both the auth cookie and the session variables are set in different places in the web config file.
yes, i've set them both to timeout in 30 minutes..

however, sometimes the session variables just disappear after a few minutes.

i should maybe ask.. when does a new session start? if you close IE and re-open then you'll have a new session, right?

but, what if you keep the same IE open, browse to somewhere else in the same site (using the absolute address) and then come back.. does the session expire??

thanks!
richard.
No the session doesnt expire if you stay on the same site.

there could be many reasons your session expired. Can your IE take cookies, I dont think its the HOST IIS that is the problem as that is overriden by your web.config file. Did you set your session variables properly ?
well.. i think i am declaring them correctly:

Session("User_ID") = 5

and then later, intUserID = Integer.Parse(Session("User_ID"))

they just sometimes disappear.. what's strange is that if the session is expired, then it should redirect the user to the login page again shouldnt it ?
I think you are misunderstanding both issues

The session Cookie ID issued by the forms Authentication is different from the session variables. If the Forms Auth Cookie expires longer, or are persistant, you will not be redirected to your login page
i think i do understanding the issues..

as i said in my initial posting, i set both the timeout of the session and the auth cookie to 30 minutes.. that is why i was surprised that the session was timing out, but not the auth cookie.

what else might cause a session variable to expire (other than time)?

0 comments:

Post a Comment