What is meant by Attaching Cookies ?

Answer Posted / sunil kumar

The withcookie() helper method is used to attach cookies.
The cookie generated with this method can be attached by calling withcookie() method with response instance.
By default, all cookies generated by Laravel are encrypted and signed so that they can't be modified or read by the client.

Example :

Route::get('/cookie',function(){
return response("Hello", 200)->header('Content-Type', 'text/html')
->withcookie('name','Virat Gandhi');
});

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is service providers?

388


Is laravel object oriented?

427


How to get current url in laravel?

443


How to configure route cache in laravel?

503


Explain the controllers in laravel?

428






What is namespace in php laravel?

408


What is csrf protection in laravel?

441


Explain what is laravel

415


What do you mean by bundles?

451


What is the default session timeout duration and how can it be set?

426


What is csrf protection?

434


How long have you been using laravel?

429


What is difference between single quote and double quote?

375


What are the Severity Levels in Laravel ?

853


Can you explain about serialization?

429