Reputation: 33956
I only want to unset play_mode however the second line also unsets landing_site.
Why is this happening?
session_start();
session_unset($_SESSION['play_mode']);
echo $_SESSION['landing_site'];
Upvotes: 0
Views: 745
Reputation: 4995
From php.net
void session_unset ( void )
The session_unset() function frees all session variables currently registered.
If you want to unset just one variable then just use unset.
unset($_SESSION['play_mode']);
Upvotes: 1
Reputation: 8259
session_unset
The session_unset() function frees all session variables currently registered.
Try this instead:
unset($_SESSION['play_mode']);
[edit]
This question needs more people linking the manual!
Upvotes: 1
Reputation:
you want unset() for a single var not session_unset() the whole session
Upvotes: 0
Reputation:
Because, as per the documentation,
The session_unset() function frees all session variables currently registered.
Also, session_unset()
takes no arguments.
If you only want to unset $_SESSION['play_mode']
, then just do unset($_SESSION['play_mode'])
.
Upvotes: 2