Laravel Auth :: logout doesn't delete remember me cookie

So, I have a two-week lifespan for my sessions, so users don’t need to log in or out several times. However, today I noticed something, if you log out, it destroys your session, but saves your cookie in memory. This causes problems because if you switch accounts to the same computer 8-10 times, you get an error with 400 errors because you are sending too much information. Now 8-10 times in the normal lifetime of the cookie is more visible, but when your life is two weeks, I ran into problems.

This is a screenshot of what happens when you enter and exit several times ago. enter image description here How to delete a cookie for life when a user logs out? So far i tried

Auth::logout(); Session::flush(); 
+7
php cookies session laravel laravel-4
source share
1 answer

The cookie does not seem to turn off automatically. However, you can do this in your controller immediately before returning a redirect response after logging out.

 public function getLogout() { // your code here ..... // Get remember_me cookie name $rememberMeCookie = Auth::getRecallerName(); // Tell Laravel to forget this cookie $cookie = Cookie::forget($rememberMeCookie); return Redirect::to('/')->withCookie($cookie); } 

Remember to reload the redirected cookie, otherwise it will not work.

+2
source share

All Articles