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.
Session or temporary cookies are deleted automatically once you close your browser. However, other cookies have a specific time of expiry in the form of date and time along with their names and values. If the website doesn't set the expiry date, the browser will delete the cookie once it's closed.
Session cookies expire once you log off or close the browser. They are only stored temporarily and are destroyed after leaving the page. They are also known as transient cookies, non-persistent cookies, or temporary cookies.
Session cookies only last as long as your browser is open and are automatically deleted when a user closes the browser or exits the app. On the other hand, persistent cookies will continue to exist even after a browser or app is closed. They are used by websites to remember a user and their preferences on a website.
To set a cookie so it expires at the end of the browsing session, simply OMIT the expiration parameter altogether. Save this answer.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With