Is it possible to delete all the session variables except a few?
I'm building a website using PHP, MySQL
$_SESSION = array_intersect_key($_SESSION, array_flip(array('leave', 'all', 'these', 'keys')));
$dontDelete = array('test1','test2');
foreach($_SESSION as $key => $value) {
if (!in_array($key,$dontDelete)) {
unset($_SESSION[$key]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With