- fixed Session length issue if MySQL is configured as Session handler, closed #666

This commit is contained in:
Mark Friedrich
2018-12-02 17:55:10 +01:00
parent 801eb0a43f
commit 295ffc8fae
3 changed files with 41 additions and 2 deletions

View File

@@ -150,7 +150,7 @@ class Controller {
){
if(!headers_sent() && session_status()!=PHP_SESSION_ACTIVE){
$session = new DB\SQL\Session($this->getDB('PF'), 'sessions', true, $onSuspect);
new DB\SQL\MySQL\Session($this->getDB('PF'), 'sessions', true, $onSuspect);
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Created by PhpStorm.
* User: Exodus 4D
* Date: 02.12.2018
* Time: 15:40
*/
namespace DB\SQL\MySQL;
class Session extends \DB\SQL\Session {
function __construct(\DB\SQL $db, string $table = 'sessions', bool $force = true, $onsuspect = null, $key = null){
if($force){
// create sessions table
// -> We use this "custom" SQl rather than the default in parent::__construct()
// because of the defaults 'data' column type TEXT
$dbName = $db->name();
$sql = "CREATE TABLE IF NOT EXISTS ";
$sql .= $dbName ? $db->quotekey($dbName,FALSE) . "." : "";
$sql .= $db->quotekey($table,FALSE) . " (";
$sql .= $db->quotekey('session_id') . " VARCHAR(255),";
$sql .= $db->quotekey('data') . " MEDIUMTEXT,";
$sql .= $db->quotekey('ip') . " VARCHAR(45),";
$sql .= $db->quotekey('agent') . " VARCHAR(300),";
$sql .= $db->quotekey('stamp') . " INT(11),";
$sql .= "PRIMARY KEY (" . $db->quotekey('session_id') . ")";
$sql .= ");";
$db->exec($sql);
}
// $force = false for parent constructor -> skip default create SQL
parent::__construct($db, $table, false, $onsuspect, $key);
}
}

View File

@@ -10,7 +10,7 @@ namespace Model;
use DB\SQL\Schema;
class MapTypeModel extends BasicModel{
class MapTypeModel extends BasicModel {
protected $table = 'map_type';