note 34979 deleted from function.session-register by didou

From: Date: Thu, 14 Aug 2003 07:01:38 +0000
Subject: note 34979 deleted from function.session-register by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54128@lists.php.net to get a copy of this message
Note Submitter: upset@sumail.ru ---- Remember, that when you use $_SESSION["var"]=$var you get $var became superglobal. This means, that having received this ($var) variable from a form (or in some other way) later, you won't be able to access it with $var - it will always be overwritten. For example: On FIRST Submit ... $var="First Submit"; // received from a form $_SESSION["var"]=$var; // registering session variable echo $var; // outputs "First Submit" ... On SECOND Submit ... $var="Second Submit"; // received from a form again echo $var; // outputs "First Submit" because $var is now the same as $_SESSION["var"] ... To aviod this I changed $_SESSION["var"] to $_SESSION["s_var"]. But I guess it's possible to access $var via $HTTP_*_VARS["var"]. Though, I didn't tried yet.

« previous php.notes (#54128) next »