Jump to content

Clearing Out SESSION


doubledee

Recommended Posts

They're generally both used to say, "hey, there's nothing useful in this session value any more."  Which one you use might be determined by the code being used to check if there is a useful value to be had.

 

For example, one script might simply check for the presence of a particular key in the $_SESSION array; if it's there then the author might have chosen to assume there is an okay value for use when he needs it.  Another script might prefer to keep that key present in the array but with a specific value to raise the same flag as the other script did by removing the key entirely. 

 

if (array_key_exists('blah', $_SESSION))
// versus
if ($_SESSION['blah'] !== '')

 

I wouldn't stress over which to choose, so long as it ties in with what your script is expecting of an empty/missing/unset session value.

Link to comment
Share on other sites

That means we should use the function unset() to clear the session data. Else if we simply set it like this $_SESSION['value'] = ''; rather than using unset() function it will consider there is a session value existing. We can understand this thing from "scootstah" post.

 

 

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.