简体   繁体   中英

How to delete a named session

I'm using named sessions to store variables for a multi-page form like this:

$_SESSION['pages'][0]
$_SESSION['pages'][1]

If I want to unset all the variables in $_SESSION['pages'][1] and I use session_unset(); it clears all the variables in both of them.

I know I can unset variables one by one using:

unset($_SESSION['pages'][1]['email'])

But I'm looking for a way to delete all of $_SESSION['pages'][1] while leaving $_SESSION['pages'][0] intact

您可以在$_SESSION['pages'][1]上使用unset ,这只是一个普通的数组。

unset($_SESSION['pages'][1]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM