Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default User System Problemo...

    Righty ho,
    Well I have this usersystem, and when they login it sets the correct row in the database so that "logged_in" is equal to 1.
    But it only changes to 0 when they press Logout.
    Is there any way to make it set to 0 when they're inactive for 1/2 hour?
    'cause I can't figure it out.

    I tryed to log the time of their last action and compare it with the current time, but that failed because when they closed the tab or window it wasn't able to refresh to time them out, hence a failure there.

    Any help appreciated and +repped.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Use a timestamp

    Add a lastaction field to the database, then add into your functions file

    PHP Code:
    $now time();
    mysql_query("update *USER DATABASE* set lastaction = '$now' where username = 'USERNAME VAR'");
    /* Un-Logs inactive people */
    $logout $now 1300;
    mysql_query("update USERDATABASE set logged_in = '0' where lastaction < $logout");
    /* End */ 
    Just did quickly so might have errors, so feel free to correct me

    I tryed to log the time of their last action and compare it with the current time, but that failed because when they closed the tab or window it wasn't able to refresh to time them out, hence a failure there.
    Ive made it so that everytime the functions file is loaded (no matter what account is logged in) it will correct all the login things before proceeding.
    Last edited by MrCraig; 06-12-2007 at 08:26 PM.
    Coming and going...
    Highers are getting the better of me

Posting Permissions

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