HI,
I was using PHP file based sessions on a Debian server, which stores the session information in /var/lib/php5, I believe.
I would like to store my sessions in the DB (MariaDB) I am already using for my webapp. So I am using the following
code at the end of index.php:
new \DB\SQL\Session($f3->get('DB'), 'session', FALSE, function($session) {
//suspect session
$logger = new \Log('tmp/ssession.log');
$f3=\Base::instance();
if (($ip=$session->ip())!=$f3->get('IP'))
$logger->write('user changed IP:'.$ip);
else
$logger->write('user changed browser/device:'.$f3->get('AGENT'));
// The default behaviour destroys the supicious session
return false;
});
$f3->run();
And tmp/ssession.log is empty - but there are other files there, .php files.
$f3->get('DB') is set correctly, my "session" table looks like this - auto created by F3:
MariaDB [XXX]> describe session;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| session_id | varchar(40) | NO | PRI | NULL | |
| data | text | YES | | NULL | |
| csrf | text | YES | | NULL | |
| ip | varchar(40) | YES | | NULL | |
| agent | varchar(255) | YES | | NULL | |
| stamp | int(11) | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
But as soon I logout, log back in nothing gets created in there, the # of records is 0.
What am I missing? It seems it insisting on file based sessions - CACHE is not set, could that be the reason?
Regards
Thomas