Jump to content

[SOLVED] Simple question about session_destroy()


nine72

Recommended Posts

Hey everyone,

Is it possible to unset and destroy a named session...example: $_SESSION['form_data'] ???

 

I have 23 named session states including my orginal login session ($_SESSION())

 

I need to unset and destory the other 22 with out loosing the login session.

 

I know that I can unset the named session by unset($_SESSION['form_data']);

 

Thanks in advance...

session_destroy() just deletes the session data file. It has no effect on $_SESSION variables present in the script. When your script ends, any $_SESSION variables present will be written to the existing or new session data file.

 

If you want to delete all session variables but one, I recommend saving that one variable in a program variable, clearing the $_SESSION variables using $_SESSION = array(); and then set your one session variable again from the program variable you set it to.

Thanks for the replies,

I have just done a test and used unset only, and it worked kind of...one of my reusable form sets still retained the previous information but only in fire fox...weird...

but I think that it will work out fine...

 

Thanks again.

 

How do i close this or mark it answered?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.