Jump to content

session destroy


jimfog

Recommended Posts

Do you think that session unset and session destroy can exist both of them in the same script? I mean, is there any rule that says, that I must have a page where I first unset the session and a 2nd page thatI destroy it?

Link to comment
Share on other sites

Somewhere in your application you want to delete some particular session variable but don't want to sign out from your application. Then you will use session_unset to unset a particular session variable. And when we log out from our application then we delete all the session data just using session_destroy().

Link to comment
Share on other sites

Somewhere in your application you want to delete some particular session variable but don't want to sign out from your application. Then you will use session_unset to unset a particular session variable. And when we log out from our application then we delete all the session data just using session_destroy().
Can you give me a more practical example of the above scenario-it was clear but I would like to have some example. Thanks
Link to comment
Share on other sites

session_unset will remove all session variables. If you want to remove a particular one just unset that one (unset($_SESSION['var'])). If you want to remove all session values you can also set $_SESSION to an empty array, $_SESSION = array(); Using session_destroy will remove all variables and also remove the session itself, if a user went to another page with session_start it would create a new session instead of using the old one.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...