Logout when Session Expires

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsunitadhn
    New Member
    • Jan 2008
    • 82

    Logout when Session Expires

    my problem is that after every 20minutes i got the error that the
    Object reference not set to an instance of an object.
    and highlight the line
    lblWelcome.Text = "Welcome, " + Session["userName"].ToString();

    I want that when the session expires either user will see LogIn page or the sesion resume their values.
    Where i write the code for the above.... thanks for your code in advance
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    Before use session checked that exists or not if not then redirect ur page to Login page

    if Session["userName"] == null then response.redire ct('');

    Comment

    • agarwalsunitadhn
      New Member
      • Jan 2008
      • 82

      #3
      Originally posted by kunal pawar
      Before use session checked that exists or not if not then redirect ur page to Login page

      if Session["userName"] == null then response.redire ct('');

      I have to record the logout time also. bt this code will not work it only to redirect to another page. becoze when the session expires then how i got the value that which user is logged in n how we record their time of logout in database

      Comment

      • kunal pawar
        Contributor
        • Oct 2007
        • 297

        #4
        Oh, then u need to maintain USer session in cookies or in hidden variable. that will help u to know which user's session expired

        Comment

        • agarwalsunitadhn
          New Member
          • Jan 2008
          • 82

          #5
          Originally posted by kunal pawar
          Oh, then u need to maintain USer session in cookies or in hidden variable. that will help u to know which user's session expired
          Thanks i had done that by storing the value in hidden field.

          Thanks once again

          Comment

          Working...