1

Quite straight forward:

public function demo(){
    $this->Cookie->delete('Auth.User');
    $this->Cookie->destroy();
    if($this->Cookie->check('Auth.User')){
        echo "yes";
    }else{
        echo "no";
    }
    die();
}

Getting "yes" all the time. Using CakePHP 2.7.3

Alvaro
  • 40,778
  • 30
  • 164
  • 336
  • Possible duplicate of [CakePHP Delete Cookie Issue](http://stackoverflow.com/questions/5655255/cakephp-delete-cookie-issue) – Jamie Bicknell Jun 29 '16 at 14:59
  • @JamieBicknell That's an answer from 2011 and they say it was solved in 2.0.0. Not a duplicated of it. – Alvaro Jun 29 '16 at 15:03
  • The problem is probably kinda similar though, deleting/destroying only empties the components `_values` property, `$_COOKIE` is left untouched, causing subsequent checks to not fail, as the value will be retrieved from the superglobal in case it's not available in `_values`. Given that the cookie is being written before `demo()` is being invoked, the check should fail on subsequent requests, otherwise the cookie will remain. – ndm Jun 29 '16 at 18:12
  • @ndm I don't really understand it. What are you suggesting to remove the cookie then ? Why the cookie still containing data even when I remove my `Cookie->write` statement? – Alvaro Jun 30 '16 at 07:04
  • You should also remove the `die()`, otherwise the empty/destroyed cookie will never be sent to the client. – ndm Jun 30 '16 at 10:18

0 Answers0