Compare commits
No commits in common. "9ade08d8bd9d9889b71cfcad650669c58fb8c5ac" and "219b42f995b8e34432da4dde77e53e24b75d78dd" have entirely different histories.
9ade08d8bd
...
219b42f995
@ -23,15 +23,15 @@ class Request implements IRequest
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $base,
|
string $base,
|
||||||
array $get,
|
array &$get,
|
||||||
array $post,
|
array &$post,
|
||||||
array $headers,
|
array $headers,
|
||||||
array &$session,
|
array &$session,
|
||||||
IUserRepository $userRepository)
|
IUserRepository $userRepository)
|
||||||
{
|
{
|
||||||
$this->base = $base;
|
$this->base = $base;
|
||||||
$this->get = $get;
|
$this->get = &$get;
|
||||||
$this->post = $post;
|
$this->post = &$post;
|
||||||
$this->headers = $headers;
|
$this->headers = $headers;
|
||||||
$this->session = new Session($session);
|
$this->session = new Session($session);
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ class Request implements IRequest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setParsedRouteParams(array $routeParams): void
|
public function setParsedRouteParams(array &$routeParams): void
|
||||||
{
|
{
|
||||||
$this->routeParams = $routeParams;
|
$this->routeParams = &$routeParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBase(): string
|
public function getBase(): string
|
||||||
|
@ -11,16 +11,13 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
{
|
{
|
||||||
private IConnection $dbConnection;
|
private IConnection $dbConnection;
|
||||||
|
|
||||||
private string $table;
|
|
||||||
|
|
||||||
private bool $exists = false;
|
private bool $exists = false;
|
||||||
|
|
||||||
private bool $written = false;
|
private bool $written = false;
|
||||||
|
|
||||||
public function __construct(IConnection $dbConnection, string $table)
|
public function __construct(IConnection $dbConnection)
|
||||||
{
|
{
|
||||||
$this->dbConnection = $dbConnection;
|
$this->dbConnection = $dbConnection;
|
||||||
$this->table = $table;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function open($savePath, $sessionName): bool
|
public function open($savePath, $sessionName): bool
|
||||||
@ -35,7 +32,7 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
|
|
||||||
public function read($id): string
|
public function read($id): string
|
||||||
{
|
{
|
||||||
$select = new Select($this->dbConnection, $this->table);
|
$select = new Select($this->dbConnection, 'sessions');
|
||||||
$select->columns(['data']);
|
$select->columns(['data']);
|
||||||
$select->whereId(substr($id, 0, 32));
|
$select->whereId(substr($id, 0, 32));
|
||||||
|
|
||||||
@ -52,7 +49,7 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
|
|
||||||
public function write($id, $data): bool
|
public function write($id, $data): bool
|
||||||
{
|
{
|
||||||
$modify = new Modify($this->dbConnection, $this->table);
|
$modify = new Modify($this->dbConnection, 'sessions');
|
||||||
|
|
||||||
if ($this->exists) {
|
if ($this->exists) {
|
||||||
$modify->setId(substr($id, 0, 32));
|
$modify->setId(substr($id, 0, 32));
|
||||||
@ -71,7 +68,7 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
|
|
||||||
public function destroy($id): bool
|
public function destroy($id): bool
|
||||||
{
|
{
|
||||||
$modify = new Modify($this->dbConnection, $this->table);
|
$modify = new Modify($this->dbConnection, 'sessions');
|
||||||
$modify->setId(substr($id, 0, 32));
|
$modify->setId(substr($id, 0, 32));
|
||||||
$modify->delete();
|
$modify->delete();
|
||||||
|
|
||||||
@ -104,7 +101,7 @@ class DatabaseSessionHandler implements ISessionHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$modify = new Modify($this->dbConnection, $this->table);
|
$modify = new Modify($this->dbConnection, 'sessions');
|
||||||
|
|
||||||
$modify->setId(substr($id, 0, 32));
|
$modify->setId(substr($id, 0, 32));
|
||||||
$modify->set('updated', (new DateTime())->format('Y-m-d H:i:s'));
|
$modify->set('updated', (new DateTime())->format('Y-m-d H:i:s'));
|
||||||
|
@ -14,7 +14,7 @@ Container::$routeCollection = new SokoWeb\Routing\RouteCollection();
|
|||||||
Container::$routeCollection->get('index', '', [{app}\Controller\HomeController::class, 'getIndex']);
|
Container::$routeCollection->get('index', '', [{app}\Controller\HomeController::class, 'getIndex']);
|
||||||
|
|
||||||
if (isset($_COOKIE['COOKIES_CONSENT'])) {
|
if (isset($_COOKIE['COOKIES_CONSENT'])) {
|
||||||
Container::$sessionHandler = new SokoWeb\Session\DatabaseSessionHandler(Container::$dbConnection, 'sessions');
|
Container::$sessionHandler = new SokoWeb\Session\DatabaseSessionHandler(Container::$dbConnection);
|
||||||
|
|
||||||
session_set_save_handler(Container::$sessionHandler, true);
|
session_set_save_handler(Container::$sessionHandler, true);
|
||||||
session_start([
|
session_start([
|
||||||
|
Loading…
Reference in New Issue
Block a user