Search code examples
androidmobilebrowsermobile-safarisession-cookies

Session Cookies expire way sooner on mobile than on desktop


We're using session cookies on our website. After 8 hours they expire. On a desktop browser (Chrome, Firefox, Edge,...) this works just fine.

But on the default Android browser (Chrome) they expire way sooner. (2 hours)

However we make no distinction between desktop or mobile when setting our session-cookie.

Is this default behaviour? And how can we extend the session time on a mobile browser?

(Tested on Android 7.1.2 with Chrome 60.0.3112.116)

But other users on other mobile devices are experiencing the same issue.


Solution

  • I suspect that your problem is that the browser instance is closed by the OS and when you open again the browser you create a new session server side. You can't do anything about this. Is like when you close the browser in a computer: when you reopen the browser and open the site you create a new session.

    You have to consider to create and use a cookie that lives more than a session cookie and save in that cookie some data that can help you recognize the user. And remember that data stored on the session server side will not be available when the previous scenario occurs.