lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
637 stars 208 forks source link

Deleting a cookie inside Myth Auth Events::on('logout') not working #549

Closed Eeel-12 closed 2 years ago

Eeel-12 commented 2 years ago

Hello, Don't know if it's relevant but just in case i post it here. I'm using Event login to set an additional cookie which work perfectly fine, and want to delete it when the Event logout is triggered, but it wasn't working.

I add to change AuthController.php

    public function logout()
    {
        if ($this->auth->check())
        {
            $this->auth->logout();
        }

        return redirect()->to(site_url('/'));
    }

to

    public function logout()
    {
        if ($this->auth->check())
        {
            $this->auth->logout();
        }

        return redirect()->to(site_url('/'))->withCookies();
    }

Now it works fine.