Adjusting the session length so a user is logged out sooner or stays logged in longer (guide)

Last updated: Fri, Mar 31, 2023 9:10 am
Return to Knowledgebase


Extending the time a user stays logged in is not as simple as it seems



This function does not take any arguments

Further Documentation:

Some hosting providers have garbage collection and other session-killing settings that are above your control. This often makes controlling the amount of time a user stays logged in somewhat non-obvious.

In general, the login time is the shortest of the following 3 criteria:

1. Whatever your hosting provider says it should be.

2. Your UserSpice cookie expiration

3. Whatever the visiting user's browser says it should be.

However, we have found that the best way to get the behavior you want is to do the following 4 things.

1. If you're trying to extend the session, download and install the Remember Me plugin from Spice Shaker or here.

2. If you want remember me to be the default experience, you can also install and enable the Default Remember Me Plugin from Spice Shaker or here.

3. In users/init.php extend the
'cookie_expiry' => 604800  //One week, feel free to make it longer

4. On the dashboard under "System Snapshot", the path to the "correct" php.ini file is usually listed. Consider adjusting the garbage collection session.gc_maxlifetime value. There is a large discussion about that over at Stack Exchange