Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Session Timeout

Session Timeout

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nethelpworkspace
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Priya Prk
    wrote on last edited by
    #1

    Dear all, I have the following configuration for my sessionState:

    >

    It works fine, but there is one thing i don't understand. When i open multiple tabs, all tabs have the same SessionID, but they don't time out at same time. I thought that all tabs share the same session, so they have to have also the same timeout :zzz: What i want is that ofter session timeout occurs, to logout the user from all opened tabs at the same time. But in my situaion, when two tabs are open, the first one logs the user out, but not from the second tab. On the second tab, the user still can work. This is my code to logout and redirect the user ofter session timeout:

    protected void Session_Start(object sender, EventArgs e)
    {
    if (Context.Session != null)
    {
    if (Context.Session.IsNewSession)
    {
    string sCookieHeader = Request.Headers["Cookie"];

                    if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET\_SessionId") >= 0))
                    {
                        //signout the user and redirect to the login page
                        FormsAuthentication.SignOut();
                        HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
                        UrlHelper urlHelper = new UrlHelper(new RequestContext(httpContext, new RouteData()));
                        string redirectUrl = urlHelper.Action("LogOn", "Account");
                        httpContext.Response.Redirect(redirectUrl);
                    }
                }
            }
        }
    

    How can i solve this issue? Thanks in advance.

    D 1 Reply Last reply
    0
    • P Priya Prk

      Dear all, I have the following configuration for my sessionState:

      >

      It works fine, but there is one thing i don't understand. When i open multiple tabs, all tabs have the same SessionID, but they don't time out at same time. I thought that all tabs share the same session, so they have to have also the same timeout :zzz: What i want is that ofter session timeout occurs, to logout the user from all opened tabs at the same time. But in my situaion, when two tabs are open, the first one logs the user out, but not from the second tab. On the second tab, the user still can work. This is my code to logout and redirect the user ofter session timeout:

      protected void Session_Start(object sender, EventArgs e)
      {
      if (Context.Session != null)
      {
      if (Context.Session.IsNewSession)
      {
      string sCookieHeader = Request.Headers["Cookie"];

                      if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET\_SessionId") >= 0))
                      {
                          //signout the user and redirect to the login page
                          FormsAuthentication.SignOut();
                          HttpContextBase httpContext = new HttpContextWrapper(HttpContext.Current);
                          UrlHelper urlHelper = new UrlHelper(new RequestContext(httpContext, new RouteData()));
                          string redirectUrl = urlHelper.Action("LogOn", "Account");
                          httpContext.Response.Redirect(redirectUrl);
                      }
                  }
              }
          }
      

      How can i solve this issue? Thanks in advance.

      D Offline
      D Offline
      Dalek Dave
      wrote on last edited by
      #2

      Does this help?[^]

      ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups