Compare commits

..

No commits in common. "d666593fde99cabaf3421f3610d0ce7c44da1cd7" and "a6ba53764bd5e17a805c2a67165dafc04ad7d412" have entirely different histories.

3 changed files with 18 additions and 13 deletions

View File

@ -10,7 +10,7 @@
} }
], ],
"require": { "require": {
"esoko/soko-web": "0.10", "esoko/soko-web": "0.7",
"fzaninotto/faker": "^1.9" "fzaninotto/faker": "^1.9"
}, },
"require-dev": { "require-dev": {

8
composer.lock generated
View File

@ -4,15 +4,15 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "db04b12ad70bbdfe83841fa292277ec6", "content-hash": "cadf44c9030f1d63cb602a2ddb77db7e",
"packages": [ "packages": [
{ {
"name": "esoko/soko-web", "name": "esoko/soko-web",
"version": "0.10", "version": "v0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.esoko.eu/esoko/soko-web.git", "url": "https://git.esoko.eu/esoko/soko-web.git",
"reference": "fd286c9cffadc4a26609bfa00944f8014a2f3f59" "reference": "88a2a99527b51dfb240ec78ac7070dc36a1022b6"
}, },
"require": { "require": {
"phpmailer/phpmailer": "^6.8", "phpmailer/phpmailer": "^6.8",
@ -33,7 +33,7 @@
"GNU GPL 3.0" "GNU GPL 3.0"
], ],
"description": "Lightweight web framework", "description": "Lightweight web framework",
"time": "2023-05-02T10:55:47+00:00" "time": "2023-04-30T18:20:27+00:00"
}, },
{ {
"name": "fzaninotto/faker", "name": "fzaninotto/faker",

21
web.php
View File

@ -4,7 +4,6 @@ use SokoWeb\Response\HttpResponse;
use SokoWeb\Routing\RouteCollection; use SokoWeb\Routing\RouteCollection;
use SokoWeb\Session\DatabaseSessionHandler; use SokoWeb\Session\DatabaseSessionHandler;
use SokoWeb\Request\Request; use SokoWeb\Request\Request;
use SokoWeb\Request\Session;
use MapGuesser\Controller\MapsController; use MapGuesser\Controller\MapsController;
use MapGuesser\Controller\HomeController; use MapGuesser\Controller\HomeController;
use MapGuesser\Controller\LoginController; use MapGuesser\Controller\LoginController;
@ -91,21 +90,27 @@ Container::$routeCollection->group('admin', function (RouteCollection $routeColl
}); });
if (isset($_COOKIE['COOKIES_CONSENT'])) { if (isset($_COOKIE['COOKIES_CONSENT'])) {
Container::$sessionHandler = new DatabaseSessionHandler( Container::$sessionHandler = new DatabaseSessionHandler(Container::$dbConnection);
Container::$dbConnection,
'sessions',
new DateTime('-7 days')
);
session_set_save_handler(Container::$sessionHandler, true); session_set_save_handler(Container::$sessionHandler, true);
session_start([ session_start([
'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand 'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
'cookie_lifetime' => 0, 'cookie_lifetime' => 604800,
'cookie_path' => '/', 'cookie_path' => '/',
'cookie_httponly' => true, 'cookie_httponly' => true,
'cookie_samesite' => 'Lax' '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 // this is needed to handle old type of session IDs
if (!Container::$sessionHandler->validateId(session_id())) { if (!Container::$sessionHandler->validateId(session_id())) {
session_regenerate_id(true); session_regenerate_id(true);
@ -119,7 +124,7 @@ Container::$request = new Request(
$_GET, $_GET,
$_POST, $_POST,
getallheaders(), getallheaders(),
new Session($_SESSION), $_SESSION,
new UserRepository() new UserRepository()
); );