SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2006
    0 Post(s)
    0 Thread(s)

    Logout if user is already logged in

    I am planning a paid service

    User pays to me I create a uid and pwd for him.

    I do not want him to share his uid and pwd to anyone.

    "A" has logged in with his credentials. Now "B" logs in with "A"s credentials. I want to log out A and log in B.

    How to acheive this is php.

    How to logout a already logged in user.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Philadephia, PA
    1 Post(s)
    0 Thread(s)
    Add a column for a session ID to your users table. When someone logs in, update their session ID in the table. On each page load, check if the session ID matches the one in the database. If not, destroy their session, logging them out.

    When "B" logs in with "A"s credentials, those credentials are updated with "B"'s session ID. When "A" who is still logged in from earlier tries to view another page, "A"'s session ID won't match the one in the table, so you destroy it and "A" is now logged out while "B" is still logged in.


Posting Permissions

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