Results 1 to 11 of 11
Thread: session managment
-
07-26-2005, 11:23 AM #1Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
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?
-
07-26-2005, 11:34 AM #2Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
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.
-
07-26-2005, 01:49 PM #3Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
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.
-
07-26-2005, 02:07 PM #4Web Hosting Master
- 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 onComputer Steroids - Full service website development solutions since 2001.
(612)234-2768 - Locally owned and operated in the Minneapolis, Minnesota area.
-
07-26-2005, 02:40 PM #5Web Hosting Guru
- 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.adamlivesley
http://84degrees.com
-
07-26-2005, 06:38 PM #6Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
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.
-
07-26-2005, 06:49 PM #7Web Hosting Guru
- 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 youadamlivesley
http://84degrees.com
-
07-26-2005, 06:53 PM #8Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
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.
-
07-26-2005, 07:08 PM #9Web Hosting Guru
- 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.
-
07-26-2005, 07:24 PM #10Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.
-
07-26-2005, 07:37 PM #11Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.