kilrizzy
kilrizzy

Reputation: 2943

PHP Defining $varname changes $_SESSION['varname']

It took me a while to realize that $_SESSION['user'] was changing because I have a variable set: $user = array();

Is this normal? I haven't had this issue until today, not sure if it is a server/php setting

Upvotes: 1

Views: 129

Answers (2)

sakabako
sakabako

Reputation: 1150

Try turning off register_globals in your php.ini file.

Upvotes: 4

jlb
jlb

Reputation: 19970

Depends on how you set $_SESSION['user'].

If you are setting it by reference then it is tied to the variable you used to set it.

ie.

$_SESSION['user'] =& $user;

$user = array();

now $_SESSION['user'] is an empty array

Upvotes: 0

Related Questions