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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.