[ASK] Login Session

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • progdoctor
    New Member
    • Jul 2008
    • 13

    #1

    [ASK] Login Session

    Friends..
    Im a newbie to PHP. I want to develop a webbased application.Acc ording to the plan this app will be stored in a server and all workstation request the app to this server.My question is how can i cover the login issues such as : if the user already logged then no one else can log in with that username again and users can login in the same time

    I really2 appreciate your help...

    Thankyou
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    you want a user to login only once? or can only have one session at a time?

    Both can be covered by another column in your users table.

    call it, is_logged_in for all i care: TYPE TINYINT(1)

    Set it to 0 (false) initially.

    When the user logs in, set it to 1. If he clicks log out, set it to 0 (or not, if you don't want them to log in again)


    Each time someone logs in check to make sure this is set to 0 before you let them in. If it is set to 1 (true), refuse the login.

    Now, if it happens someone accidentally closes the browser and doesn't log out. Now he can't log back in.

    In this case, what you can do is also make another field called "from_ip" and put $_SERVER['remote_address '] (they're IP) into it.

    If they happen to login from the same IP, log them in no matter what the current status of "is_logged_ in" field is (true or false)


    Get it? Go it? Good.


    Dan

    Comment

    Working...