is 'user_id' a keyword in $_SESSION['user_id']?
Sattar_kuet.bd’s Question:
I have studied the following code:
$this->user_id = $_SESSION['user_id']=$user->id;
but $_SESSION['user_id']
this does not make any sense to me. ‘user_id’ inside $_SESSION[] is not any name attribute or input field name. So is user_id is a keyword reserved in php? if so what is the significance of this keyword?
$_SESSION
are super global variables which store values in SESSION and can be accessed like arrays. So user_id
is just an index of a value in Session not a reserved keyword.
On the following statement
$this->user_id = $_SESSION['user_id']=$user->id
;
Value from $user -> id
is stored in two places (1) $this -> user_id
and (2) $_SESSION['user_id']
Just like user_id
a session can hold any random indices. For example
$_SESSION['asdfsafasfsadfasd'] = 'aasfsafasfasfasfasf';