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

后端 未结 9 602
耶瑟儿~
耶瑟儿~ 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:48

    If you want to avoid the warning:

    Warning: session_destroy(): Trying to destroy uninitialized session in ... on line 18

    Don't forget to add session_start(); to the beginning of your code. Other than that the code you provided works as intended.

提交回复
热议问题