Welcome Guest, Not a member yet? Register   Sign In
Timestamp is always '0000-00-00 00:00:00' in ci_sessions table
#1

(This post was last modified: 07-06-2021, 01:41 AM by louieuow.)

Hi All
I am referring to CI 4.1.3
There is a bug in the system file Session\Handlers\DatabaseHandler.php in the function "public function write($sessionID, $sessionData): bool"
I added this line of code  (below) just above the 2 "return true;"  lines in this function (lines 225 and 251)
$fp = fopen('c:\temp\session.txt', 'a'); fwrite($fp,$this->db->getLastQuery()."\n");fclose($fp);
To write out the queries that are used to update the ci_sessions table when $sessionDriver is set to the DatabaseHandler.
The following is the sample SQL statements for both and INSERT and an UPDATE of ci_sessions generated by this function 
//-------------------------
INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('qtigi184f4bh2joblluam9t2a78sioeb', '130.130.211.181', 'now()', '__ci_last_regenerate|i:1625558640;session_id|s:32:\"qtigi184f4bh2joblluam9t2a78sioeb\";_ci_previous_url|s:57:\"http://chios.ad.uow.edu.au/law_lip/public/index.php/login\";')

UPDATE `ci_sessions` SET `timestamp` = 'now()', `data` = '__ci_last_regenerate|i:1625558640;session_id|s:32:\"qtigi184f4bh2joblluam9t2a78sioeb\";_ci_previous_url|s:57:\"http://chios.ad.uow.edu.au/law_lip/public/index.php/login\";status|s:2:\"OK\";user_id|s:2:\"la\";account_type|i:1;user_rec_id|s:1:\"1\";user_rec|s:0:\"\";menus|s:0:\"\";application_id|i:0;'
WHERE `id` = 'qtigi184f4bh2joblluam9t2a78sioeb'

//-----------------------------------
The issue causing  the Timestamp to be stored as '0000-00-00 00:00:00' is that the MySQL function NOW() is in quotes so it is treated as a string and timestamp is not assigned the value of NOW(), but the string 'NOW' (the error is in red font above).
This function will have to be adjusted so that NOW() is not quoted when the SQL is generated
Regard
louieuow
Reply


Messages In This Thread
Timestamp is always '0000-00-00 00:00:00' in ci_sessions table - by louieuow - 07-06-2021, 01:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB