Click to See Complete Forum and Search --> : Session Destroy


Jaelan
12-03-2004, 03:53 PM
Ok, I have a question about sessions in general and how to destroy them.

I understand the general principle of setting up sessions, using them, unsetting them. And I know to call session_destroy() to end a session. However, I've read it's also good practice (for memory reasons, I assume) to unset all the SESSION variables. But say I have many SESSION variables that I don't want to keep track of when I finally destroy the session. Is there an array of SESSION variables that I could just loop through and unset them somehow?


Jaelan

dreamcatcher
12-04-2004, 08:21 AM
Use the unset() function to unset as many variables as you like:

unset($variable1,$variable2,$variable3);

etc etc

96turnerri
12-05-2004, 12:15 PM
i think what he wants is

foreach($_SESSION as $key => $val) {
unset($key);
//leave echo in here for testing purposes the make sure it works, take it out once tested
echo $key."-".$val Unset";
}

Jaelan
12-06-2004, 08:41 AM
Yeah, 96,

That's about what I was asking. Thanks!

Jaelan

96turnerri
12-06-2004, 09:32 AM
glad to have helped