也许做这样的事情
foreach($_SESSION as $key => $val) { if ($key !== 'somekey') { unset($_SESSION[$key]); } }
foreach($_SESSION as $key => $val) { if ($key !== 'somekey') { unset($_SESSION[$key]); } }