From 4601c4bd8a8e242987bd0aa6209e7aac67f962ee Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 1 Aug 2017 21:02:24 -0400 Subject: [PATCH] Fix "PHP Warning: session_write_close(): Failed to write session data (user)" errors - Changed returning true when there's a session ID but no session data in ref_session_write() - Moved session.php requires around --- boot.php | 2 ++ include/notifier.php | 1 - include/poller.php | 1 - include/rockstar.php | 1 - include/session.php | 8 ++++++-- index.php | 2 -- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/boot.php b/boot.php index d2f8634e..0f4f36a4 100644 --- a/boot.php +++ b/boot.php @@ -1,5 +1,7 @@ set_baseurl(get_config('system', 'url')); diff --git a/include/session.php b/include/session.php index e51dbc1b..a125679f 100644 --- a/include/session.php +++ b/include/session.php @@ -30,10 +30,14 @@ function ref_session_write($id, $data) { global $session_exists, $session_expire; - if (!$id || !$data) { + if (!$id) { return false; } + if (!$data) { + return true; + } + $expire = time() + $session_expire; $default_expire = time() + 300; @@ -65,7 +69,7 @@ function ref_session_gc($expire) { q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time())); q("OPTIMIZE TABLE `sess_data`"); - + return true; } diff --git a/index.php b/index.php index 082f0c0e..07ddb75a 100644 --- a/index.php +++ b/index.php @@ -24,8 +24,6 @@ unset($db_host, $db_user, $db_pass, $db_data); $a->init_pagehead(); $a->page['aside'] = '
Your friends. Your web.
'; -require_once 'session.php'; - session_start(); if ((x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {