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

en2ie's avatar

Session cookie value keeps changing?

I have noticed that the laravel_session cookie value changes with each request, just curious to if this is working properly?

I tried googling but keep getting threads about sessions not persisting (which I am not having a problem with).

0 likes
8 replies
en2ie's avatar

Thanks, yeah I have found that thread before. Their problem seems to be with new sessions being created for each request, mine keeps the session (I am using the database driver if that matters at all) but the cookie value in the browser changes.

I am not sure if this is even a problem, everything works as intended as far as I can tell. Also it is worth noting that looking at the session cookie for laracasts.com it also changes with each request...

bobbybouwmann's avatar

It might have something to do with the hashing of the value of the cookie. The hash will always be unique so it could change.

Hussam3bd's avatar

I had the same issue, I tried a lot of solutions and nothing worked for me.

My case: The token keeps changing on every request only when the session driver is set to database, and it works just fine on file and Redis driver.

After a lot of debugging, I found that the issue was not with session config, it was from the payload column in the session table in the DB.

I changed the payload column from text to longText, and it worked!

Hussam3bd's avatar

@Snapey sure thing, but when you store something in session it will be stored in the database and only the session ID will be stored in cookies. I don't think this will be affected, don't you agree?

Snapey's avatar

@Hussam3bd I agree, yes, Sorry, the size of the session is a problem for cookie based session storage.

However, the TEXT field in the sessions table should be more than adequate. If you are having problems with the size of this column (64MB) then you are saving way too much data in session.

1 like
Hussam3bd's avatar

@Snapey That's correct, and indeed we have a lot of data in sessions, we had a big code refactoring 💃

Please or to participate in this conversation.