gevensen Posted July 13, 2009 Share Posted July 13, 2009 I have used unset to unset a session variable For example unset($_SESSION['name']; The problem I am having is every so often it clears other session variables So my question is should I not be using unset to unset a single session variable? Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2009 Share Posted July 13, 2009 unset() only operates on the variable you specify. If you are having a problem with other session variables it is not being cause by unset(). You would need to pin down what is causing the other session variables to be changed. Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874599 Share on other sites More sharing options...
gevensen Posted July 13, 2009 Author Share Posted July 13, 2009 thats what i thought but wanted to make sure i have written a log file in to help track down the issue which appeared only after using unset() Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874700 Share on other sites More sharing options...
.josh Posted July 13, 2009 Share Posted July 13, 2009 off the top of my head, couple things to check for: a) make sure you are using session_start(); on all of your pages b) make sure you aren't accidentally for instance doing unset($_SESSION); Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874704 Share on other sites More sharing options...
phporcaffeine Posted July 13, 2009 Share Posted July 13, 2009 Also, make sure that in every instance where you are using unset that you are also using the appropriate/desired array index. For example, if I accidentally used unset($_SESSION) ... I would wipe out all sessions for that user, regardless of the array indexes. Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874705 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2009 Share Posted July 13, 2009 I've got to ask, what does a phpinfo(); statement show for register_globals? Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874707 Share on other sites More sharing options...
phporcaffeine Posted July 13, 2009 Share Posted July 13, 2009 I'm not sure I understand the question but I'll answer from every angle I can think of. phpinfo(); is a helpful (and dangerous) read-only core method within the PHP language. The displayed results will give very detailed info about the configured php runtime environment on your server and all the things available. register_globals() is a function that you can call in your scripts to tell php to make a variable available to all parts of a script regardless of scoping. It is mostly discouraged from use not because it is a faulty function but because of a general lack in understanding of the function and how to use it responsibly (as it can be a very dangerous function when used in a vulnerable script or incorrectly). Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874721 Share on other sites More sharing options...
.josh Posted July 13, 2009 Share Posted July 13, 2009 PFM was asking the OP to put that in his code and post whether register globals is on or off... Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874730 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2009 Share Posted July 13, 2009 And register_globals ain't a function anyways. Quote Link to comment https://forums.phpfreaks.com/topic/165810-unset-problem/#findComment-874738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.