Reputation: 1700
I have this piece of code:
var thisUser = Session["user"];
if (thisUser == null)
{
LogFile.Log("Logging out");
Response.Write("xp");
}
I am trying to track down why sometimes when I play with the system for a few minutes and suddenly the user
session variable gets null.
It happens randomly in different scenarios.
I do not set the Session["user"]
to null at any point.
Session timeout is set to 20 minutes.
I do not call Session.Clear()
at any point.
Any ideas\thoughts\things I should look at as to why is it may happening?
I am using Firefox if that to any help.
The system is built with asp.net.
For more info please ask.
Upvotes: 1
Views: 2828
Reputation: 7591
are you calling the same host? if the base URL is different the server will treat this as different users. for example:
http://localhost/path/to/resource
and http://localhost:80/path/to/resource
both point to the same resource, but the requests are different and the session cookie will be different, or not present.
An easy way to test this is to launch your browser's developer toolbar and monitor the network traffic. compare the URLs to make sure they are the same base path and the same session cookie is passed in the request.
Upvotes: 1
Reputation: 136174
Editing the web.config will recycle the app pool, which clears the session info.
Upvotes: 0
Reputation: 423
First of all this looks like C# and ASP.NET, not classic ASP. Now if you never clear the session yourself and the server (or the app pool) is never restarted, then the only way to lose the session is to clear the browser's cookies.
Upvotes: 0