jimfog Posted October 3, 2012 Share Posted October 3, 2012 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 More sharing options...
rahultailwal Posted October 3, 2012 Share Posted October 3, 2012 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 More sharing options...
jimfog Posted October 3, 2012 Author Share Posted October 3, 2012 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 More sharing options...
justsomeguy Posted October 3, 2012 Share Posted October 3, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now