I am able to set a plain old cookie like this:

$cookie = new HttpCookie('myCookie', 'myValue');

I am trying to delete it like this:

$cookie = new HttpCookie('myCookie', '');
craft()->request->getCookies()->add($cookie->name, $cookie);

When I make a call to check the cookie, I get this returned:


I can see that the value is getting cleared, but is there any way to just totally wipe out the cooke?


Try deleteCookie() in HttpRequestService?

  • Thanks khalwat, that pointed me in the right direction. I've also updated my other question that is related to this for anyone who comes across this question. – Damon Feb 4 '16 at 20:43

I wasn't able to find an answer for removing a cookie in Craft 3 so after plenty of time of trying to figuring it out, this is my conclusion.

First of all, I am setting the cookie using the following method.

$cookie = new Cookie(['name' => 'cookieName']);
$cookie->value = $data['accessToken'];
$cookie->expire = $data['expires'];

I kept running into a problem with the Cookies being set are read-only so in order to remove the cookie need to use response to change and remove cookies.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.