Session name as variable name problem
eg:
$_SESSION['user']="sample"; //this is session variable
$user="data"; // this is variable
when i get session value it will display variable value like this
echo $_SESSION['user'];
expeted result : sample
but it display : data
how?
Session name as variable name
Moderator: General Moderators
Re: Session name as variable name
I think there's a setting in php.ini that automatically imports $_POST, $_GET, $_SESSION, and $_COOKIE variables into the local variable space - sort of like automatically calling extract($_POST), etc at the head of every file. I can't remember what the setting is though.
If you find it, you can either change php.ini, or call ini_set() to change that setting.
If you find it, you can either change php.ini, or call ini_set() to change that setting.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: Session name as variable name
Or, if you are on a shared host and/or don't want to mess with php.ini settings, use variable names that are different from $_SESSION index names. But pickle is right, there is some such setting, and it can make you think you have gone nutzoid if you don't know about it.
Re: Session name as variable name
register_globals directivepickle wrote:I think there's a setting in php.ini that automatically imports $_POST, $_GET, $_SESSION, and $_COOKIE variables into the local variable space - sort of like automatically calling extract($_POST), etc at the head of every file. I can't remember what the setting is though.
If you find it, you can either change php.ini, or call ini_set() to change that setting.