How to modify or remove php session variables

First you have to open the session for modify or remove session variables.
session_start();

To change a variable, just overwrite it.
$_SESSION[‘name’]=’your_name’;

To remove a single variable in the session.
unset($_SESSION[‘name’]);

To remove all the variables in the session. (without destroying the session)
session_unset();

To destroy the session.
session_destroy();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: