newbie85 — 2011-03-31T14:53:08-04:00 — #1
I use sharing hosting and I am wondering how sessions works.
For example, I use session when user submit form and when I submit data to database, I put the following lines:
Is that enough or is there any extra step I should do? When this session will be deleted from server?
chris_upjohn — 2011-03-31T18:28:04-04:00 — #2
You can also use session_destory() which removes all information associated with the current user session.
jream — 2011-03-31T18:52:03-04:00 — #3
you have to make sure you have
session_start() at the top so you have access to the $_SESSION variables
newbie85 — 2011-04-03T03:46:13-04:00 — #4
But this will remove all sessions, I would like to keep some sessions. I was just worried if using only unset won't spend too much resources if those session are never deleted but only unset.
ernie1 — 2011-04-03T17:28:37-04:00 — #5
You can use a custom mysql based session handler to delete the session where data is empty:
$old = time() - $max;
$old = mysql_real_escape_string($old);
$sql = "DELETE FROM sess WHERE access < '$old' or data=''";
return mysql_query($sql, $_sess_db);