Reputation: 12047
I am trying to save a session as either 1 or 0 and setup its key via another variable. Although when I go to use the SESSION data, it is not there. I am using the below code and would appreciate any advice.
session_start();
$num ='1';
$_SESSION[$num] =='0';
if(isset($_SESSION[$num])){
echo 'ran';
}
Upvotes: 0
Views: 433
Reputation: 4630
Only use one equal sign = not two ==
$_SESSION[$num] = '0';
Upvotes: 0
Reputation: 30488
$_SESSION[$num] =='0';
this should be
$_SESSION[$num] ='0';
=
is used for assignment and ==
used for comparison
Upvotes: 4
Reputation: 11467
This is comparison, not assignment:
$_SESSION[$num] =='0';
Use a single equals sign:
$_SESSION[$num] = '0';
Upvotes: 4