3

How I will identify whether my login session is expired or user logged out.As I am trying to show some message after users session timeout and redirect to login page. I also googled for it but not get satisfactory answer. Can anybody please guide me, how I need to check this.

Thanks in advance

gofor.net
  • 4,218
  • 10
  • 43
  • 65
  • This might not be the correct solution, but its a work around. Your application might have log out button, you can check that the current user have clicked that button any time or not, if he has clicked then the User has logged out otherwise the session is expired. – Gopesh Sharma Oct 01 '13 at 11:38
  • http://stackoverflow.com/questions/10480110/how-to-check-whether-session-is-expired-or-not-in-asp-net might help. – KrishnaDhungana Oct 01 '13 at 11:41

2 Answers2

0

To check your log in session,change the value of session time out in settings of applications. Keep it to some 3-5 minutes so that you can test it quickly. for that time do not perform any action and after some try to access your tool.you must be logged off of you application.

Yasmeen Ansari
  • 319
  • 2
  • 4
  • 15
0

You may set a cookie when login is successful:

Response.Cookies.Add(new HttpCookie("login_status", "1"));

And when user presses "Log out", you either delete the cookie or set it to another value:

Response.Cookies.Add(new HttpCookie("login_status", "0"));

Then it's easy to check in Page_Load event of the login page:

HttpCookie loginStatusCookie = Request.Cookies["login_status"];
if(loginStatusCookie != null && loginStatusCookie.Value == "1")
{
     //User did not log out explicitly.
     //Display timeout message.
}
else
{
     //User either logged out or it is his/her first visit.
     //Display usual greeting.
}
IMil
  • 1,391
  • 13
  • 17