Tuesday, February 5, 2013

How to modify or remove session on php


The php code demonstrates how to edit or remove individual session variables, or the entire session.
Here PHP Code :


 // you have to open the session to be able to modify or remove it 
session_start();

// to change a variable, just overwrite it
$_SESSION['username']='demo_value';

//you can remove a single variable in the session
unset($_SESSION['email']);

// or this would remove all the variables in the session, but not the session itself
session_unset();

// this would destroy the session variables
session_destroy();
Disqus Comments