Merge pull request 'feature/session-handler-changes' (!63) from feature/session-handler-changes into develop
All checks were successful
mapguesser/pipeline/head This commit looks good
All checks were successful
mapguesser/pipeline/head This commit looks good
Reviewed-on: #63
This commit is contained in:
commit
184f63585c
@ -10,7 +10,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"esoko/soko-web": "0.7",
|
||||
"esoko/soko-web": "0.10",
|
||||
"fzaninotto/faker": "^1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -4,15 +4,15 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "cadf44c9030f1d63cb602a2ddb77db7e",
|
||||
"content-hash": "db04b12ad70bbdfe83841fa292277ec6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "esoko/soko-web",
|
||||
"version": "v0.7",
|
||||
"version": "0.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.esoko.eu/esoko/soko-web.git",
|
||||
"reference": "88a2a99527b51dfb240ec78ac7070dc36a1022b6"
|
||||
"reference": "fd286c9cffadc4a26609bfa00944f8014a2f3f59"
|
||||
},
|
||||
"require": {
|
||||
"phpmailer/phpmailer": "^6.8",
|
||||
@ -33,7 +33,7 @@
|
||||
"GNU GPL 3.0"
|
||||
],
|
||||
"description": "Lightweight web framework",
|
||||
"time": "2023-04-30T18:20:27+00:00"
|
||||
"time": "2023-05-02T10:55:47+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fzaninotto/faker",
|
||||
|
21
web.php
21
web.php
@ -4,6 +4,7 @@ use SokoWeb\Response\HttpResponse;
|
||||
use SokoWeb\Routing\RouteCollection;
|
||||
use SokoWeb\Session\DatabaseSessionHandler;
|
||||
use SokoWeb\Request\Request;
|
||||
use SokoWeb\Request\Session;
|
||||
use MapGuesser\Controller\MapsController;
|
||||
use MapGuesser\Controller\HomeController;
|
||||
use MapGuesser\Controller\LoginController;
|
||||
@ -90,27 +91,21 @@ Container::$routeCollection->group('admin', function (RouteCollection $routeColl
|
||||
});
|
||||
|
||||
if (isset($_COOKIE['COOKIES_CONSENT'])) {
|
||||
Container::$sessionHandler = new DatabaseSessionHandler(Container::$dbConnection);
|
||||
Container::$sessionHandler = new DatabaseSessionHandler(
|
||||
Container::$dbConnection,
|
||||
'sessions',
|
||||
new DateTime('-7 days')
|
||||
);
|
||||
|
||||
session_set_save_handler(Container::$sessionHandler, true);
|
||||
session_start([
|
||||
'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
|
||||
'cookie_lifetime' => 604800,
|
||||
'cookie_lifetime' => 0,
|
||||
'cookie_path' => '/',
|
||||
'cookie_httponly' => true,
|
||||
'cookie_samesite' => 'Lax'
|
||||
]);
|
||||
|
||||
if (isset($_COOKIE[session_name()])) {
|
||||
// extend session cookie lifetime is cookie already exists
|
||||
setcookie(session_name(), session_id(), [
|
||||
'expires' => time() + 604800,
|
||||
'path' => '/',
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax'
|
||||
]);
|
||||
}
|
||||
|
||||
// this is needed to handle old type of session IDs
|
||||
if (!Container::$sessionHandler->validateId(session_id())) {
|
||||
session_regenerate_id(true);
|
||||
@ -124,7 +119,7 @@ Container::$request = new Request(
|
||||
$_GET,
|
||||
$_POST,
|
||||
getallheaders(),
|
||||
$_SESSION,
|
||||
new Session($_SESSION),
|
||||
new UserRepository()
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user