Today's Question:  What does your personal desk look like?        GIVE A SHOUT

strange thing in PHP session variable and local variable

  Pi Ke        2011-06-13 12:23:59       4,450        0    

A few minutes ago, I noticed one strange thing when I did my PHP web application development.

The situation is described below:
I want to display a user's profile using a query parameter user=user_id as the parameter. And also the session variable when user logs in  is $_SESSION["user"].So before displaying the user's profile, I need to either get the query string parameter user and create a local variable called $user and assign value to it as $user=$_REQUEST["user"].Here comes the strange thing,every time after the local variable $user is changed,the session variable $_SESSION["user"] is also changed to the value of $user. How come?But after i change the variable name from $user to $user_id, all strange things are gone.

The reason why this happens still remains as a mystery. Some more effort will be taken to find the reason.Keep going1

If any of you knows the reason.You can post it on the comment window. I appreciate your help.

PHP  SESSION  VARIABLE NAME  CHANGE AUTOMAT 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.