PHP会话在移动浏览器上销毁太快

I have the following issue. I am building a PHP + jQuery mobile website and I want to maintain the PHP session. The problem here is that when I close the browser App (Samsung Galaxy S4/S5 or Google Chrome on Android) and I leave the phone for say, ten minutes, and then reopen the browser, the whole session appears to be destroyed and I have to log in again.

I tried to increase the cookie lifetime like this:

ini_set('session.cookie_lifetime', 60 * 60 * 24);
ini_set('session.gc-maxlifetime', 60 * 60 * 24);
session_start();

But this does not solve it. I think it is because the browser app purges the session data after some time of inactivity.

Note that I do not want to use "remember me" functionality, I just want to use the PHP session ID.

What would be the correct way to solve this? I have looked at local storage but it seems strange the browser App purges the entire session and I am looking for the simplest solution.

I fixed it (after a lot of trying out) using the php.ini setting

session.gc_maxlifetime = 3600

After doing this, the mobile browser kept the session alive. Even if I put my phone away for a longer period.

Apparently setting the maxlifetime does not work if done through a script.

Instead of trying to modify the ini values try using the session_set_cookie_params function like so:

session_set_cookie_params(60 * 60 * 24);
session_start();