Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 414
J-B Avatar asked Sep 13 '17 13:09

J-B


People also ask

Do computer cookies expire?

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.

Why do cookie sessions expire?

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.

How long does it take for browser cookies to expire?

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.

How do cookies expire at end of session?

To set a cookie so it expires at the end of the browsing session, simply OMIT the expiration parameter altogether. Save this answer.


1 Answers

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.

like image 114
anemomylos Avatar answered Oct 14 '22 03:10

anemomylos