shasews Posted April 21, 2011 Share Posted April 21, 2011 On pp. 254-255, in script 9.8, in the example it shows unset($_SESSION); but the text uses session_destroy(); Hence, the text doesn't match the example. My instructor says to use both. Is that wise or necessary? What exactly is the difference between the two, is one better to use than the other? Or is it best to use both? Thanks! Sharon Link to comment Share on other sites More sharing options...
Cooper Posted April 27, 2011 Share Posted April 27, 2011 On pp. 254-255, in script 9.8, in the example it shows unset($_SESSION); but the text uses session_destroy(); Hence, the text doesn't match the example. My instructor says to use both. Is that wise or necessary? What exactly is the difference between the two, is one better to use than the other? Or is it best to use both? Thanks! Sharon Hi! I think you should use session_destroy() because if you don't, the session data will remain on the server until you close the browser. But I need the correct answer too. Maybe Larry will answer us. Link to comment Share on other sites More sharing options...
Jonathon Posted April 27, 2011 Share Posted April 27, 2011 This is from the manual albeit it is user comments at the bottom The difference between both session_unset and session_destroy is as follows: session_unset just clears out the sesison for usage. The session is still on the users computer. Note that by using session_unset, the variable still exists. Using session_unset in tandem with session_destroy however, is a much more effective means of actually clearing out data. As stated in the example above, this works very well, cross browser: session_unset(); session_destroy(); I noticed that in firefox, one could simply use sesison_unset and the session would be cleared. When trying this on IE, I was horrified to find out that the data was still there, so I had to use session destroy. Full reference Link to comment Share on other sites More sharing options...
Larry Posted May 2, 2011 Share Posted May 2, 2011 Ugh! Drives me nuts when I make mistakes like this. Apologies for the confusion. The code in the steps is correct, the script is not. It should be: session_start(); $_SESSION = array(); // Wipes out the variable. session_destroy(); // Removes the actual data on the server. Ugh! Link to comment Share on other sites More sharing options...
shasews Posted May 3, 2011 Author Share Posted May 3, 2011 Thank you! Sharon Link to comment Share on other sites More sharing options...
Recommended Posts