开发者

Session variables return completely after unsetting

开发者 https://www.devze.com 2022-12-29 05:58 出处:网络
I have a script th开发者_JAVA百科at should log the user out of the site. It unsets all $_SESSION and $_COOKIE variables related to the login data of the user. But somehow, it seems impossible to log o

I have a script th开发者_JAVA百科at should log the user out of the site. It unsets all $_SESSION and $_COOKIE variables related to the login data of the user. But somehow, it seems impossible to log out. I checked the $_SESSION array at the end of the logout script, and at the beginning of each page. At the end of the logout script it says 'array()', but when I click the home button - or any link on the site - the full session data is back again and I don't know where it comes from. This is how I try to unset the session data: unset($_SESSION); unset($_COOKIE["usid"]); unset($_COOKIE["pw"]); unset($_COOKIE["adm"]); -- I don't know how to put it on different lines, but it's not that hard to read.

Why do these data keep coming back?!


The PHP documentation says "Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal."

Try out this in stead: $_SESSION = array(); (as recommended on the PHP documentation).

0

精彩评论

暂无评论...
验证码 换一张
取 消