note 42643 added to ref.session
| From: | webmaster at webpages1 dot com | Date: | Tue, 25 May 2004 03:25:36 +0000 |
| Subject: | note 42643 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70047@lists.php.net to get a copy of this message | ||
This drove me crazy for a long time trying to figure out why my $_SESSION vars were changing
(seemingly by themselves). I finally realized that assigning a value to a regular variable with the
same name as a session variable will overwrite the session variable.
$_SESSION['testing'] = "test@foo.com";
$testing = "test@bar.com";
echo $_SESSION['testing'];
// will output test@bar.com
another example:
$_SESSION['email_address'] = "test@foobar.com";
// mysql query here...
while($row = mysql_fetch_assoc($result)) {
stripslashes(extract($row));
}
/* If there is a column named email_address in the mysql result,
$_SESSION['email_address'] will change with every iteration of the while loop. */
I had mistakenly thought that _SESSION variables did not interfere/conflict with regular variables.
----
Manual Page -- http://www.php.net/manual/en/ref.session.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42643
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42643&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42643&report=yes
Search -- http://master.php.net/manage/user-notes.php