Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to Create Creating a Cookie in Laravel ?



How to Create Creating a Cookie in Laravel ?..

Answer / rishabh khanna

Cookie can be created by global cookie helper of Laravel.
It is an instance of SymfonyComponentHttpFoundationCookie.
The cookie can be attached to the response using the withCookie() method.
Create a response instance of IlluminateHttpResponse class to call the withCookie() method.
Cookie generated by the Laravel are encrypted and signed and it can’t be modified or read by the client.


Here is a sample code with explanation.

//Create a response instance
$response = new IlluminateHttpResponse('Hello World');

//Call the withCookie() method with the response method
$response->withCookie(cookie('name', 'value', $minutes));

//return the response
return $response;

Cookie can be set forever by using the forever method as shown in the below code.

$response->withCookie(cookie()->forever('name', 'value'));

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Laravel PHP Framework Interview Questions

What is name route in laravel?

0 Answers  


What are helper functions and name 10 with their purposes?

0 Answers  


What are the Steps for Creating a Blade Template Layout ?

1 Answers  


How can you exclude uris from csrf protection in laravel?

0 Answers  


What is view routes?

0 Answers  


What are the site types supported by homestead?

0 Answers  


Tell us can laravel be hacked?

0 Answers  


What do you understand by unit testing?

0 Answers  


Explain how to do 301 redirects in laravel?

0 Answers  


What is ssrf attack?

0 Answers  


What is middleware in laravel?

0 Answers  


How to Passing Data to Views ?

1 Answers  


Categories