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

jeevan628's avatar

Session cookie value changes

With every request to server, the session cookie value changes. This poses a problem on mobile since we have multiple processes making api calls and changing cookies seems to breaking stuff. We are going to run the application over ssl when deployed so we don't want the cookie values to change. We are fine with the remember_me cookie changing because that happens rarely and only when used. Correct me if I am wrong.

How do I go about preventing the cookie value from changing on every request? Or is there something we are doing wrong on mobile (Android specific)?

0 likes
5 replies
bashy's avatar
  1. Laravel 4/5?
  2. If it's Laravel 5, have you got an up-to-date version from source?
  3. Are you storing sessions properly, permissions to write to sessions folder/database etc?
  4. What session storage are you using?
  5. What settings do you have set in config/session.php?
jeevan628's avatar

Hi,

  1. I'm on 4.2.
  2. Sessions are being written to database.
  3. driver = database, lifetime = 120, expire_on_close = false, connection = null (maybe should change to match my db? but still populates), table = sessions, lottery = array(2,100), cookie = companyname, path = '/', domain = null, secure = false.

The cookie companyname comes with different value each time. I like this from server dev perspective but it is an issue for mobile.

Anything I can change to make them static-y?

bashy's avatar

That should be enough... do cookies save on the mobile version?

jeevan628's avatar

They are. But the cookie value changes with each request? Is there any way to disable it?

bashy's avatar
bashy
Best Answer
Level 65

It shouldn't be like that if all is setup right and the browser accepts cookies.

If it's not storing it on the browser, Laravel will re-generate one on each request because the client did not send it with the request.

Please or to participate in this conversation.