The cookie shown in the picture, I want to clear the ES_name cookie
Set up a route
<code>Route::get('/admin/test', function(){ response('')->withCookie(cookie('ES_name','',-1)); });</code>
Then the cookie is still there after accessing /admin/test
Replace routing with
<code>Route::get('/admin/test', function(){ setcookie('ES_name', '', -1, '/'); });</code>
It doesn’t work either. Using Cookie’s forget or make settings still doesn’t work. It can only be cleared by changing the address to a first-level route like /logout.
Is it a BUG in laravel, or did I not notice what needs to be set?
The cookie shown in the picture, I want to clear the ES_name cookie
Set up a route
<code>Route::get('/admin/test', function(){ response('')->withCookie(cookie('ES_name','',-1)); });</code>
Then the cookie is still there after visiting /admin/test
Replace routing with
<code>Route::get('/admin/test', function(){ setcookie('ES_name', '', -1, '/'); });</code>
It doesn’t work either. Using Cookie’s forget or make settings still doesn’t work. It can only be cleared by changing the address to a first-level route like /logout.
Is it a BUG in laravel, or did I not notice what needs to be set?
Thank you, I succeeded according to your method, I will study it again.
<code>$cookie = Cookie::forget('ES_name'); return Redirect::route('admin')->withCookie($cookie);</code>
This is because after setting the cookie, you need to redirect it to take effect, because the http response will operate the cookie change to take effect.