problem with session data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Vantuykom
Forum Newbie
Posts: 19
Joined: Fri Jul 04, 2003 6:22 am

problem with session data

Post 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
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post 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.
Vantuykom
Forum Newbie
Posts: 19
Joined: Fri Jul 04, 2003 6:22 am

Post by Vantuykom »

can you tell me an easy way to check time-differences?
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post 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
Post Reply