Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default A PHP Session query :S?

    Hi,

    My minds gone blank, how would I set sessions and ensure the user will be logged in until either their password changed or some other stuff I set had changed.

    Would I have to set a cookie with a random string assigned to that user and set the session automatically? :S

    Im confused... All I want is it to be abit like vbulletin where it keeps you logged in,...

    Thanks +REP for help.

    Thanks, Lew.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    vBulletin sets a "remember me" cookie if I remember correctly. It has a special "key" in it that is located in the database.

    Everytime your user logs in, update their column: key in the users table with say an MD5 hash of the time + their user ID.

    Then on your check login method, if they're determined not logged in... check the cookie.. if the cookie contents matches the secret key in the database, treat it as a username + password correct and log them in.

  3. #3
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    vBulletin sets a "remember me" cookie if I remember correctly. It has a special "key" in it that is located in the database.

    Everytime your user logs in, update their column: key in the users table with say an MD5 hash of the time + their user ID.

    Then on your check login method, if they're determined not logged in... check the cookie.. if the cookie contents matches the secret key in the database, treat it as a username + password correct and log them in.
    That what I thought of eventually, although I havent had time to work on my script, I still need to work on it as it throws up a couple of errors

    Lew.
    Im not here to be loved, I love to be hated :-}


  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    One thing most people don't think of is cleaning the input from the cookie

  5. #5
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Another thing I didnt think of is using time() as the md5 hashed token. Cos the value would change by the time it had set the cookie, took me ages to find out why it wouldnt work Now, I'm using a random string

    Lew.
    Im not here to be loved, I love to be hated :-}


  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    You could use time to set the cookie...

    PHP Code:
    $random_string md5(time());
    // set cookie stuff here  //
    setcookie("userhash"$random_stringtime() + 2592000); // expires after 30 days. 

  7. #7
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    You could use time to set the cookie...

    PHP Code:
    $random_string md5(time());
    // set cookie stuff here  //
    setcookie("userhash"$random_stringtime() + 2592000); // expires after 30 days. 
    But wouldnt that change if it executed twice or something I havent had a play with it yet soo...

    Lew.
    Im not here to be loved, I love to be hated :-}


  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Why would it need to be executed twice? Remember this cookie is only set on login... not every check_user..

Posting Permissions

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