Help delet session variables in a mysql db

Alexej Kubarev

New member
well... its quite hard to do that... why would you pu them in a DB at the first place?

y dont you simply keep them in Sessions and nothing more?

But if you want it so much --- put the expire date to the table... so when the next user visits you should call a function that will check all the expiration dates and remove the unused ones...

but as you understand, if u put a Session in a database it will only work for 1 user... so i wouldnt do it if i were you..
record the last time they were accessed and have a cleanup function that deletes the records after a set amount of time has lapsed.
Using a mysql session handler based with session_set_save_handler(), you can easily handle that.

ini_set('session.cache_expire', 0);
so that a session will be deleted after the user closes the browser.

For the time format you can use VARCHAR(14) and saving it as TIMESTAMP (with php's time() function).