Page 1 of 1

problem with session data

Posted: Tue Nov 25, 2003 4:33 am
by Vantuykom
Hi,

I'm building a program for time-management. I need a way to know if a user is allready logged in, so an account is only used once at the time.
I did find a way when the user klicks the logout button, its not very hard that way, but when the user just closes the browser, I'm in trouble.
Since I'm an ordinary programmer, programming applications that have to work on all servers, I don't have access to the php.ini-file.

No, I'm looking for a way to delete the old session-data (or sessions themselves) on the server.
It would be nice if I could make it work that when a session is inactive for lets say 15 minits, it will be deleted on the server.
I am not aware if this is hard to do with php.

I hope there is somebody out there that can help me
Thanx

Posted: Tue Nov 25, 2003 4:38 am
by bionicdonkey
store the session data in a database of some kind. when the user goes to a page it changes a time in the database. if the time is greater than the defined time, delete it.

Posted: Tue Nov 25, 2003 4:44 am
by Vantuykom
can you tell me an easy way to check time-differences?

Posted: Tue Nov 25, 2003 4:54 am
by bionicdonkey
if you store the time as a unix timestamp it's as simple as:
if (currentTimestamp > recordedTimestamp + (15 * 60)) {
session id old
}

unix timespamps are in seconds