Reputation: 7650
I used to the to send response with a cookie by this way:
return $response->withCookie(cookie()->forever('region', $region));
It works perfectly. But now I want to send a response with multiple cookies set, could anyone please give me some suggestion about that?
Upvotes: 6
Views: 7186
Reputation: 2543
You can use Cookie queues to queue them, so that they will be automatically attached to the response when it is ready.
Cookie::queue(Cookie::forever('region', $region));
Cookie::queue(Cookie::forever('region2', $region2));
Upvotes: 8
Reputation: 3205
return $response
->withCookie(cookie()->forever('region', $region))
->withCookie(cookie()->forever('somethingElse', $somethingElse));
Upvotes: 14