Results 1 to 11 of 11
  1. #1

    session managment

    i'm making a site blog for my site and i want to use sessions, probem is, i have a question if a user is on a page but stays on it for an hour i want the session to do something, i dont want him to be logged out completely but i want him to be logged out after hes inactive after a long time, but i want him to appear as logged off, to others if he is inactive for 5 mins or more. can someone tell me how i'd do this with php and mysql?

  2. #2
    Create a system for tracking of users clicks. For each click your user makes, store a timestamp (fastest would be to another session, but I've seen most people are storing it to a database).

    Taking in note that timestamp of last users activity, you can produce any calculation you need - when was the last time that user was active, how many minutes passed after his last click etc.

  3. #3
    Ok, i know that but lets say i was on this forum for like 5 hours inactive, would i be logged out?, would i appear offline but still be logged on? would i remain logged on forever like till next week, or would it log me out tommorow, would i appear offline till next week, all these questions confuse me.

  4. #4
    Join Date
    Jun 2003
    Location
    United States of America
    Posts
    1,847
    i think what maxymizer is trying to say is your last clicks time would keep you in a list if your last click was less than 5 minnutes old

    a cookie on your computer would keep you logged into the forum itself or whatever you got going on
    Computer Steroids - Full service website development solutions since 2001.
    (612)234-2768 - Locally owned and operated in the Minneapolis, Minnesota area.

  5. #5
    Join Date
    Oct 2002
    Location
    York, United Kingdom
    Posts
    279
    Just set a session time out?!?! You can set this in your php.ini file or using a .htaccess file.

    You can find more infomation here :

    http://uk.php.net/manual/en/ref.session.php


    For a site i have built the user isnt allowed to stay logged in for more than 1 hour then they must relogin. So on every click it checks the session and checks the current time then works out how far long its been. If:

    time logged in > 1 hour ---> Destroy session.

  6. #6
    no you dont get it earlier i was on the forum for 4 hours, yet when i came back i was still classed as signed in.

  7. #7
    Join Date
    Oct 2002
    Location
    York, United Kingdom
    Posts
    279
    ohh So you want to keep people signed in ?

    If you didnt close the browser its a session that never expirys enless you close the browser. Or its like WHT and uses Cookies so it remembers you

  8. #8
    No, you all dont understand, i dont want users to sign in every few seconds but i dont want them to leave and then come back to find themselves still logged in cause the session never expired. Yet i dont want a user to go out for an hour come back and find that they've been logged out.

  9. #9
    Join Date
    Feb 2003
    Location
    L.A. C.A.
    Posts
    346
    Dude, simply record the time of there last action in the session.

    $_SESSION['lastact']=time();

    Then simply compare it with a mktime of say -5 hours and if its more than 5 hours, session_destroy?

    Do you understand or do you want code examples, I'm extremely tired so I would have to write in the morning.

  10. #10
    i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.

  11. #11
    i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.

Posting Permissions

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