Skip to content

Commit

Permalink
fix custom db session handlers for changes in PHP7.1
Browse files Browse the repository at this point in the history
As of PHP 7.1, $_SESSION is no longer intialized if the custom session
read handler returns false or null. With $_SEESION not initialized, the
the custom session write handler is not getting called (just close()).

The way the ONA customer session handlers are written, this new PHP behavior
results new sessions never being written to the database.
  • Loading branch information
framer99 committed Nov 22, 2018
1 parent d6129ca commit 7ac31e4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions www/include/adodb_sessions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ function sess_read($key) {
printmsg("sess_read($key) called", 6);

list($status, $rows, $record) = db_get_record($SESS_DBH, 'sessions', "`sesskey` = '$key' AND `expiry` > " . time());
if ($status or $rows == 0) { return false; }
if ($status or $rows == 0) { return ''; }

if (array_key_exists('sessvalue', $record)) {
// Update the expiry time (i.e. keep sessions alive even if nothing in the session has changed)
$expiry = time() + $SESS_LIFE;
list($status, $rows) = db_update_record($SESS_DBH, 'sessions', "`sesskey` = '$key' AND `expiry` > " . time(), array('expiry' => $expiry));
if ($status) { return false; }
if ($status) { return ''; }

// Return the value
// Return the value (but not a null)
if ( $record['sessvalue'] == NULL ) { return ''; }
return($record['sessvalue']);
}

return false;
return '';
}


Expand Down

0 comments on commit 7ac31e4

Please sign in to comment.