How to set, get and remove cookies in Laravel? 1

Cookies are used to store information or data in the user's browser. To create cookies in Laravel, use the following step:

Step 1:

Add the following code to the top of the controller:



use Cookie;

Step 2:

Now create or set the cookie using the following code:




Cookie::queue('cookie_name', cookie_value, time_in minutes);







Cookie::queue('id', ''1234, $minute);


Step 3:

Use the following code to get the cookie you set previously:



$cookie_id= Cookie::get('id');


Step 4:

You can destroy or remove a cookie by following lines: