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. user session management issue

user session management issue

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
5 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.
  • A Offline
    A Offline
    Amit Agarrwal
    wrote on last edited by
    #1

    hello, If i want that if some body have logged in on my portal with his user name and pwd.and at same time same user tries to logged in from different computer with his user name and pwd then system should tell him that "you are already logged in with this user name and pwd." how can i achieve this in asp.net c# application. thanks in advance. Regards Amit

    Amit Agarwal

    N 1 Reply Last reply
    0
    • A Amit Agarrwal

      hello, If i want that if some body have logged in on my portal with his user name and pwd.and at same time same user tries to logged in from different computer with his user name and pwd then system should tell him that "you are already logged in with this user name and pwd." how can i achieve this in asp.net c# application. thanks in advance. Regards Amit

      Amit Agarwal

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      This is most frequently asked question. There is a search box on the right top corner. You will find plenty of answers if you use that. To answer the question, you need keep a flag in the database which will be set when user logs in and unset when logs out. When a user logs in, check the status of this flag and if it is set, say that user has logged already. This method is not fully foolproof. A common problem of this approach is your flag will not reset if user closes the browser without logging out. Hooking JS method on window close and doing AJAX request to reset the flag is one possible option. But since JS can be turned off at the client side, this method is not reliable. A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit. A combination of all these methods will work well.

      Best wishes, Navaneeth

      A 1 Reply Last reply
      0
      • N N a v a n e e t h

        This is most frequently asked question. There is a search box on the right top corner. You will find plenty of answers if you use that. To answer the question, you need keep a flag in the database which will be set when user logs in and unset when logs out. When a user logs in, check the status of this flag and if it is set, say that user has logged already. This method is not fully foolproof. A common problem of this approach is your flag will not reset if user closes the browser without logging out. Hooking JS method on window close and doing AJAX request to reset the flag is one possible option. But since JS can be turned off at the client side, this method is not reliable. A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit. A combination of all these methods will work well.

        Best wishes, Navaneeth

        A Offline
        A Offline
        Amit Agarrwal
        wrote on last edited by
        #3

        thank you so much for the very nice and approchable answer. i got two of your answers. but "A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit." can you please little Elaborate this approach.how to record the users last activity time. and in the search box what will the correct keywords to find out the answer. Thanks

        Amit Agarwal

        _ N 2 Replies Last reply
        0
        • A Amit Agarrwal

          thank you so much for the very nice and approchable answer. i got two of your answers. but "A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit." can you please little Elaborate this approach.how to record the users last activity time. and in the search box what will the correct keywords to find out the answer. Thanks

          Amit Agarwal

          _ Offline
          _ Offline
          _Damian S_
          wrote on last edited by
          #4

          Amit Agarrwal wrote:

          how to record the users last activity time

          Whenever there's a postback (ie: the user submits a form etc, clicks a button, whatever), simply call a function that updates a field in your user table with the current date/time.

          I don't have ADHD, I have ADOS... Attention Deficit oooh SHINY!! Booger Mobile (n) - A bright green 1964 Ford Falcon - our entry into the Camp Quality esCarpade!! Do something wonderful - make a donation to Camp Quality today!!

          1 Reply Last reply
          0
          • A Amit Agarrwal

            thank you so much for the very nice and approchable answer. i got two of your answers. but "A better approach is to record the last activity time of the user and a database job resets the flag if current time - last activity time is greater than session expiry limit." can you please little Elaborate this approach.how to record the users last activity time. and in the search box what will the correct keywords to find out the answer. Thanks

            Amit Agarwal

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            I meant exactly what Damian said. This will allow you to identify how long a user is inactive and reset the flag if he is inactive for long time.

            Best wishes, Navaneeth

            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