cookie delete laravel 7 code example

Example: laravel remove cookie

Set cookie: Cookie::queue(Cookie::make('cookieName', 'value', $minutes));

Get cookie: $value = $request->cookie('cookieName'); 
or $value = Cookie::get('cookieName');

Forget/remove cookie: Cookie::queue(Cookie::forget('cookieName'));

Check if cookie exist: Cookie::has('cookiename'); 
or $request->hasCookie('cookiename') will return true or false

For more detail, you can refer to the documentation:

https://laravel.com/docs/5.7/requests#cookies
https://laravel.com/api/5.7/Illuminate/Contracts/Cookie/Factory.html

Tags:

Php Example