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. Application object + logged in users

Application object + logged in users

Scheduled Pinned Locked Moved ASP.NET
4 Posts 3 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.
  • H Offline
    H Offline
    Hemant Thaker
    wrote on last edited by
    #1

    Hi.. I am working on a web application and storing logged in user to application object. once they signout its entry will be deleted from application object - application["Loggedinusers"] ( I have stored arraylist as list of logged in users) So , once the session ends by signout or timeout user gets deleted. But it doesn't work when user closes the browser without logging out. Means the entry is not deleted from Logged in users. So next time if he logs in, " It says you are already logged in".... Can you provide me the way to resolve this. Thanks,

    By: Hemant Thaker

    B 1 Reply Last reply
    0
    • H Hemant Thaker

      Hi.. I am working on a web application and storing logged in user to application object. once they signout its entry will be deleted from application object - application["Loggedinusers"] ( I have stored arraylist as list of logged in users) So , once the session ends by signout or timeout user gets deleted. But it doesn't work when user closes the browser without logging out. Means the entry is not deleted from Logged in users. So next time if he logs in, " It says you are already logged in".... Can you provide me the way to resolve this. Thanks,

      By: Hemant Thaker

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like

      function CheckBrowser()
      {

      , Alt+F4 , File -> Close

      if(window.event.clientX < 0 && window.event.clientY <0)
      {
      window.open("Temp.aspx",
      "Operation",'left=12000,top=1200,width=10,height=1');
      }
      }

      here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State

      Cheers!! Brij Check my latest Article :A walkthrough to Application State

      H T 2 Replies Last reply
      0
      • B Brij

        See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like

        function CheckBrowser()
        {

        , Alt+F4 , File -> Close

        if(window.event.clientX < 0 && window.event.clientY <0)
        {
        window.open("Temp.aspx",
        "Operation",'left=12000,top=1200,width=10,height=1');
        }
        }

        here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State

        Cheers!! Brij Check my latest Article :A walkthrough to Application State

        H Offline
        H Offline
        Hemant Thaker
        wrote on last edited by
        #3

        Hi.. thanks, its biggest resolution so far. well.. how about calling CheckBrowser() function in master page As I am using master page. Can I use thanks,

        By: Hemant Thaker

        1 Reply Last reply
        0
        • B Brij

          See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like

          function CheckBrowser()
          {

          , Alt+F4 , File -> Close

          if(window.event.clientX < 0 && window.event.clientY <0)
          {
          window.open("Temp.aspx",
          "Operation",'left=12000,top=1200,width=10,height=1');
          }
          }

          here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State

          Cheers!! Brij Check my latest Article :A walkthrough to Application State

          T Offline
          T Offline
          T M Gray
          wrote on last edited by
          #4

          I wouldn't use a window.open as that can be annoying and/or scary to users. I would probably use a XMLHttpRequest from the javascript since that is much less visible. Also another trick for pages that do not need to show the user anything and are just to update server-side info is set the http status code to 204. Another option is to set a cookie when they close the browser. Whenever someone comes to your site check for the "ImReallyLoggedOut" cookie before showing the message.

          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