i have get the username in session variable while im login, after i logged in i checked whether the session object(username) is null or not to get the username displayed in my page.if the session object is null i make the page to redirect to login page again. but at certain point if i click any link in any of my page after login it redirected me to Login page, but i havent click logout button. why it makes the session null. wat has to be placed to carry out the session variable througout the pages i visit, instead i click logout it should not be cleared / null- asp.net
-
you need to show your sssion check?Muhammad Akhtar– Muhammad Akhtar2009-12-07 06:35:51 +00:00Commented Dec 7, 2009 at 6:35
-
Are you putting the username into session on successful authentication/login?Russ Cam– Russ Cam2009-12-07 07:07:48 +00:00Commented Dec 7, 2009 at 7:07
Add a comment
|
3 Answers
Loss of session state is usually from either:
- Session timeout
- AppPool recycling due to inactivity (20 min) or daily forced recycle
- Trying to use a web garden or a web farm with InProc session state
Having said that, I would suggest using the ASP.NET Membership system instead of session state to record user login data. Either that or switch to cookies and get rid of sessions entirely.
Comments
It sounds like your session is timing out. You can increase this in your web.config – e.g.
<authentication mode="Forms">
<forms loginUrl="xxxx" timeout="60"/>
</authentication>
1 Comment
Lex Li
Session timeout belongs to <sessionstate> tag.
Session can time out and all session variables are lost. So please check if that's the case.