How do I delete PHPSESSID on client computers

前端 未结 13 1658
滥情空心
滥情空心 2020-12-30 22:50

UPDATE ON THE PROBLEM:

  • On some browsers, we have two PHPSESSIDs.
  • One PHPSESSID is not set by me anywhere in my script
  • It has
13条回答
  •  一个人的身影
    2020-12-30 23:18

    Just provide the 4th argument when calling setcookie function :

    setcookie ("PHPSESSID", "", time() - 3600, '/');
    

    Explanation

    The 4th argument of the setcookie() function is $path of the session to be set. And for this, "The default value is the current directory that the cookie is being set in.". (See : http://php.net/manual/en/function.setcookie.php.) So if you are calling this function from a file locating in folder "/folder", it will try to delete a cookie from that folder only. By setting the $path to "/" we are telling the function to delete the session_id from the root directory.

    I have tested it and it deleted the PHPSESSID from the cookie successfully.

提交回复
热议问题