
07-26-2005, 11:23 AM
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
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
|
|
Web Hosting Evangelist
|
|
Join Date: Apr 2005
Posts: 521
|
|
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
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
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
|
|
Web Hosting Master
|
|
Join Date: Jun 2003
Location: United States of America
Posts: 1,831
|
|
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
|

07-26-2005, 02:40 PM
|
|
Web Hosting Guru
|
|
Join Date: Oct 2002
Location: York, United Kingdom
Posts: 260
|
|
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.
|

07-26-2005, 06:38 PM
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
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
|
|
Web Hosting Guru
|
|
Join Date: Oct 2002
Location: York, United Kingdom
Posts: 260
|
|
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 
|

07-26-2005, 06:53 PM
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
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
|
|
Web Hosting Guru
|
|
Join Date: Feb 2003
Location: L.A. C.A.
Posts: 334
|
|
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
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.
|

07-26-2005, 07:37 PM
|
|
Junior Guru
|
|
Join Date: Mar 2005
Posts: 211
|
|
i'm not iusing $_SESSIONs i'm using database sessions like phpbb does.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|