- fixed Session length issue if MySQL is configured as Session handler, closed #666
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
39
app/main/db/sql/mysql/session.php
Normal file
39
app/main/db/sql/mysql/session.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Model;
|
||||
|
||||
use DB\SQL\Schema;
|
||||
|
||||
class MapTypeModel extends BasicModel{
|
||||
class MapTypeModel extends BasicModel {
|
||||
|
||||
protected $table = 'map_type';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user