chern123's avatar

Cookie::queue not attaching to response

Looking at the Laravel documentation, it appears you can attach a cookie to your next outgoing response by utilizing the Cookie::queue method. However, after trying to do so, it looks like the cookies are not being passed back:

Cookie::queue('client_cookie', 'test', 1000);

I have tried variations where you pass in a Cookie::make(), Cookie::Forever(), but none of these work.

However, simply doing the following appears to return a cookie:

return response('success', 200)->withCookie(Cookie::make('client_cookie', 'Testing', 1000));

Am I doing something incorrectly? I pulled in the Cookie class by using 'use Cookie;'

Is there some additional package I need to pull in?

0 likes
2 replies
chern123's avatar
chern123
OP
Best Answer
Level 3

For anyone else that runs into this problem: It looks like this middleware is only included for the 'web' group. I was making API calls, and so the queue method was not available.

2 likes

Please or to participate in this conversation.