Thursday, March 22, 2012

Session variables

This is a very wierd problem, but I have a ssimple log on page that never works the first time you use it. For example, if you successfully log into the page, it redirects you to the default page after setting a session variable. The first time you successfully log in, you get redirected to the default page, but no session variables are created. The second time you successfully log in, the session variables are created and the redirect happens.

The log on must always be done twice for the session to be created. And I know it's not a problem with mistyping the login or password because if that happens you get the invalid password message.

Also when I logout, which simply calls Session.Abandon() and then redirects, I must also do this twice before the session is abandoned.

Has anyone had problems like this?It's hard to guess without seeing the code but when I get different values (or no values) where certain values are expected, I insert a Trace.Warn() statements (enable tracing first) to track where the problem is originating from. That can tell me alot.

Also Session.Abandon() doesn't dereference the object automatically. It only becomes unavailable in the next request. IOW, it requires another request to realize the empty session.

If this doesn't help, feel free to post further details.

0 comments:

Post a Comment