Is this a proper way to destroy all session data in php?

后端 未结 9 453
耶瑟儿~
耶瑟儿~ 2020-11-27 18:21

Got it from php.net, but I am not sure is this how everybody destroy all sessions?

// Unset all Sessions
$_SESSION = array();

if (isset($_COOKIE[session_nam         


        
9条回答
  •  有刺的猬
    2020-11-27 18:43

    session_name() is the name that's passed in the cookie / querystring. It's normally PHPSESSID but can be changed.

    There's no proper way to destroy all sessions. As @Marius says, you could try deleting the session files from session_save_path() but that's a hack at best.

    Alternatively you could use session_set_save_handler() to save your sessions to somewhere you have more control over, such as a database.

提交回复
热议问题