how to destroy all session variables in php?
A PHP session can be destroyed using the sessions_destroy() function. It does not require any arguments and a single command can erase all session variables. If you’re looking to eliminate one session variable, you can use the unset() function . It will remove the session variable.
You can also try following code: use within php tag
session_start();
$helper = array_keys($_SESSION);
foreach ($helper as $key){
unset($_SESSION[$key]);
}
For More stubborn Sessions we can try
session_start();
session_unset();
session_destroy();
session_write_close();
setcookie(session_name(),'',0,'/');
session_regenerate_id(true);
Add your comment