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 do you know about closures in laravel?

555


What is use of laravel?

534


What is database migration. How to create migration via artisan?

504


How to enable maintenance mode in laravel 5?

514


What are route parameters?

536


What is mvc laravel?

522


Tell me how can you display html with blade in laravel?

518


Explain me how to assign multiple middleware to laravel route ?

586


What is database migration in laravel? How to use this?

497


How to check if value is sent in request?

539


What is laravel language?

519


What is laravel illuminate?

535


What is meant by Laravel - Localization ?

1121


State the difference between authentication and authorization.

507


What is laravel homestead?

534