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

yigitozmen's avatar

Cookie expire date is wrong

Hi, when i look the developer tools i see that the cookie's expire time is past! In this situation firefox create new session for each request. I checked php timezone and laravel timezone, they are same. Why does it happen? Can you help me please? I don't know how to fix it.

0 likes
6 replies
Snapey's avatar

Expiry time is in UTC and should be 2 hours in the future. Are you East of London?

yigitozmen's avatar

@Snapey I'm from Turkey and our timezone is GMT3 by the way i got this problem only in remote hosting. I don't have this problem in my local server. And by the way, there is no problem with all session data but in my project, firstly I transfer data from session to variable then I flush the session and transfer data back from variable to session for each search request.

Such as:

$token = session('_token'); session()->flush(); session()->put('_token', $token); session()->put('locale', $locale);

    if(isset($loggedUser))
    {

        session()->put('loggedUser', $loggedUser);
    }

All data is transferred in this technique but $loggedUser couldn't. I don't know why, it works in my local but it won't work in remote server. Only $loggedUser effected from this problem.

I don't know why. But sametime I created a route and just returned _token for seeing what happens. In local _token doesn't change for each search request but in remote every request _token changes.

I don't know why.

Remote uses https, does it cause the problem?

Cronix's avatar

is the server's time correct on the remote host? Is the date/timezone correct in php for that location on that remote host?

Snapey's avatar

sounds like your cookies are fine then, and it is quite normal to regenerate the cookie each request so that it does not expire.

I don't follow what you are doing with the session though? It makes no sense. Data saved in the session should be retained without fetching it, refreshing the session and saving again. This seems pointless to me,

Please or to participate in this conversation.