choppermio
choppermio

Reputation: 131

How Delete session by the name

How delete php session by the name example i have session['sec'] and session['page'] i need to delete session['page'] with out delete session['sec']

Upvotes: 3

Views: 9343

Answers (3)

Vishal
Vishal

Reputation: 2181

// for a single variable
unset($_SESSION['session_var']); 

// destroy the Session, not just the data stored!
session_destroy();

// delete the session contents, but keep the session_id and name:
session_unset();

Upvotes: 6

Patrick
Patrick

Reputation: 3450

You wouldn't be deleting the session in this case, only the session variable. So just do:

unset($_SESSION['page']);

Upvotes: 2

c.hill
c.hill

Reputation: 3233

This should do it:

unset($_SESSION['page']);

Upvotes: 1

Related Questions