I'm having trouble keeping my session alive, it times out after 3 hours (our desired custom timeframe) regardless of user activity. It used to keep the session alive for the next 3 hours every time somebody changes pages on the site. Now i get the "Headers already sent" error in the error log every time somebody changes pages. The session is created correctly but it cant be updated without the headers already sent error occurring.
My session_start function is added to wordpress init action, as suggested in the wordpress docs. I've simplified the code to the bare minimum and still no success.
function checkmateStartSession()
{
if(!session_id())
{
session_name('SESCHECKMATEID');
session_start(['cookie_lifetime' => 300]); // 5 minutes for testing purposes
}
}
add_action('init', 'checkmateStartSession', 1);
I've tried output buffering with ob_start() before the session_name() line and ob_end_flush() after session_start() to no avail.
I've disabled the plugins folder, problem persisted.
Changing the theme deactivates the functions.php file in which my session code lives, so the code goes back to wordpress default session code. Am I missing something in a newer update? This code used to work.