Question: How to keep session alive for 1week without logout PHP, overwriting default server values?

I need to do this in the PHP code.

Answer: 
You can set the session lifetime in your script by using the session\_set\_cookie\_params -function call before the session is started. The first argument of the function call defines the session lifetime in seconds relative to the server time (so make sure the server clock is correct):

For example, to make a session last a week:

```
session_set_cookie_params(3600 * 24 * 7);
session_start();

```

This will override the setting in the php.ini -file.

Make sure to check up on the function documentation on the PHP -site: <http://www.php.net/manual/en/function.session-set-cookie-params.php>
Alternative solution:

You say people are leaving open their browsers for days and complain that session expire. Simple solution: don't let session expire by sending an keep-alive request using eg. XMLHttpRequest every 10 minutes.