Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Cookies with domain set cannot been deleted

Hello all,

I found a problem this morning is that a cookie set with a domain cannot been removed by delete() function:

$expire = time() + 86400 * $this->config->user->rememberDays;
$this->cookies->set('RMU', $user->id, $expire, "/", false, $this->config->cookie->defaultDomain);
$this->cookies->set('RMT', $token, $expire, "/", false, $this->config->cookie->defaultDomain);

It's not work use:

    if ($this->cookies->has('RMU')) {
        $this->cookies->get('RMU')->delete();
    }
    if ($this->cookies->has('RMT')) {
        $this->cookies->get('RMT')->delete();
    }

What's the problem?



12.3k
Accepted
answer
edited Jul '15

I'm not sure what's the point in getting the cookie and then deleting it when you could delete it directly. Try: $this->cookies->delete("RMT");