Extend Session Logout Time

Ben
Extend Session Logout Time
Ben@84171e7c Monday 24th July 2023, 16:58:55

If you find yourself needing to login in too frequently, here's how to extend this.

To change the session timeout to a longer period of time (e.g., 2 hours) before automatically logging out, you need to set the session.gc_maxlifetime value using the ini_set() function.

Before you start, first make a backup of the header.php file.

Then you can modify the header.php file as shown:

Open the header.php file in the root folder of your Flatboard install with a text or code editor.
Locate the section where session_start() is called. It looks like this:

if (!session_id()) session_start();
$token = CSRF::generate();


Then you need to add the following code above the session_start() function line to set the session timeout to 2 hours:

// Set the session timeout to 2 hours (120 seconds)
$sessionTimeoutSeconds = 120;

// Set the session.gc_maxlifetime configuration option using ini_set()
ini_set('session.gc_maxlifetime', $sessionTimeoutSeconds);


Save your changes and now forum users will stay logged in for 2 hours of inactivity before being automatically logged out.

The 120 session timeout can be changed to fit your preference. Multiply the number of hours you want your session to last by 60 and replace 120 with this number. Don't set it for too long as this can pose a security risk.

Reply 1
SurveyBuilder-Admin
SurveyBuilder-Admin  Monday 24th July 2023, 22:12:18

That would be great, but certain server hosting disallows ini_set functions.
Software engineer, creates plugins for Flatboard, checks source codes, and answers any software errors questions and contributes on the GitHub page as well

Suggested Topics
started
16.8K 0
Fred
23.6K 1
hello#67a44 started markdown
General Questions
25K 6
jacK
jacK@bff71521 started Problem @mail ?
Feature Requests
28K 2
Want to read more? Browse all categories or view latest topics.