how to unset all the session variables ?/

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

how to unset all the session variables ?/

Post by susrisha »

i want to unset all the session variables for a certain code. then i want to destroy the session. how is it done??

my present code is given below

Code: Select all

 
unset($_COOKIE[session_id()]);
     session_regenerate_id();
     session_destroy();
 
 
Now i want to unset all the variables in session before it gets destroyed. can anyone tell me how to do this??
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: how to unset all the session variables ?/

Post by papa »

Example from php.net:

Code: Select all

            session_unset();
            session_destroy();
            $_SESSION = array();
Post Reply