Results 1 to 5 of 5
  1. #1
    Vamsi is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Logging out a user when browser is closed

    I have a java servlet which is connected to a database X. X has 4 fields in it
    1.User name
    2.logged in time
    3.logged out time
    4.Is logged in.

    Whenever a user logsout from the application, those 4 fields get updated. I have used cookies to store username in log in servlet and called it in logout servlet.

    Now, if the user does not logout but just closes his browser, he must be anyways logged out, and those 4 fields must get updated ..which am not able to do.

    Any help is appreciated. Thank you.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default Re: Logging out a user when browser is closed

    That's not generally the best way of determining the state of someone's login in a webapp.
    Normally you'd simply rely on the Session.
    You have no idea when the browser is shut down.
    Without some form of monitoring of last access or somesuch this isn't generally doable.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Vamsi is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default Re: Logging out a user when browser is closed

    Actually whenever a user closes his browser and opens it again, he is prompted to login..So i say virtually he is logged out.. but those fields in the database are not updated. SO log out is not complete in real sense. So u say this is not doable???

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Logging out a user when browser is closed

    Quote Originally Posted by Vamsi View Post
    So u say this is not doable???
    Did you read the last line of the response posted by Tolls?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default Re: Logging out a user when browser is closed

    Quote Originally Posted by Vamsi View Post
    Actually whenever a user closes his browser and opens it again, he is prompted to login..So i say virtually he is logged out.. but those fields in the database are not updated. SO log out is not complete in real sense. So u say this is not doable???
    They're not "virtually logged out".
    I suspect it simply clears the cookies or something, which is entirely browser side.

    This is doable, but you need more data in the database and a separate process that logs out users that have no active session id (using something like a session monitor).
    It won't be instant, it will take however long the session timeout is plus the monitoring period.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 0
    Last Post: 11-17-2011, 05:52 AM
  2. Safari browser not logging off
    By satyan in forum Java Applets
    Replies: 1
    Last Post: 08-09-2011, 10:40 AM
  3. Replies: 1
    Last Post: 01-31-2010, 04:17 AM
  4. if any user disables the browser's scripting execution then how can I know?
    By vishnujava in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 08-06-2008, 07:21 PM
  5. Socket Closed!
    By rameshraj in forum Networking
    Replies: 0
    Last Post: 05-06-2008, 11:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •