Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MacTavish's avatar

Unable to get cookies values if Session has expired

I am storing some cookies using Cookie::queue('key', $value, 1577847);. I can get the value normally using $request->cookie('key').

However, sometimes the session will expire while the user is browsing through and when I am accessing the value of cookies, I won't get anything.

Is there any way to get my cookies even if the session has expired?

0 likes
2 replies
Snapey's avatar

You may need to keep an eye on the cookie in the browser development tools. Check its expiry time and see that it disappears in the browser

MacTavish's avatar

they don't disappear from browser dev tools and their expiry time is correct as I set it. like I said, if session expires, I won't get the cookie value when i do $request->cookie('key'). I am logging it to a file whenever I access cookies. in telescope, I won't see those cookies in Cookie header when the session expires.

Could it be anything related to cookie encryption or could be something wrong in the config?

Please or to participate in this conversation.