CodeIgniter Forums
What do the Response::deleteCookie() do? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: What do the Response::deleteCookie() do? (/showthread.php?tid=75448)



What do the Response::deleteCookie() do? - tonynamy - 02-07-2020

Hello,

I'm using JWT authentication with CI4, and I was making sing up function with the code below :

Code:
return $this->response
            ->deleteCookie('access_token')
            ->redirect('/');

But it doesn't work like what I expected, so I debugged on Reponse::deleteCookie() like :
Code:
public function deleteCookie(string $name = '', string $domain = '', string $path = '/', string $prefix = '')
    {
        if (empty($name))
        {
            return $this;
        }

        d($this->cookies);
        exit;
...

And I found that there is nothing in $this->cookies, so I'm very confusing.
The remarks of Response::deleteCookie() says, "Sets a cookie to be deleted when the response is sent."
But I think it doesn't work properly.

Am I doing something wrong?

P.S.
I'm setting cookies for jwt with the code below : 
Code:
$cookie = [
            'name'   => 'access_token',
            'value'  => $jwt,
            'expire' => '86500', // 1day
            'path'   => '/',
            'secure' => TRUE,
            'httponly' => FALSE
        ];

return $this->response
            ->setCookie($cookie)
            ->redirect('/');