Welcome Guest, Not a member yet? Register   Sign In
cookie problem (Solved)
#1

(This post was last modified: 03-06-2021, 01:43 PM by neoneeco.)

Hello,

I have a problem with a logout function. I think this is a CodeIgniter bug. I want to delete the authentication cookie when the logout function is called. But with the code below, the cookie is not deleted (it is as if the redirection was done faster than the deletion). The cookie reappears on my main page. When I remove the redirect line, the cookie is deleted. Do you have the same problem ?

PHP Code:
    public function logout()
    {
        
        delete_cookie
('auth');

        session()->destroy();
        
        
return redirect('/');

    
Reply
#2

(This post was last modified: 03-06-2021, 12:58 PM by iRedds.)

PHP Code:
//use 
return redirect('/')->withCookies();
//or 
return redirect('/')->deleteCookie('auth'); 
delete_cookie() works with the Response instance.
redirect() works with the RedirectResponse instance. Although it extends the Response class, the instance is different.
Reply
#3

It works

Thank you very much
Reply




Theme © iAndrew 2016 - Forum software by © MyBB