Compare commits

...

2 Commits

Author SHA1 Message Date
4aca432257
RVRNEXT-33 session should be valid for a session
All checks were successful
rvr-nextgen/pipeline/pr-master This commit looks good
2023-05-02 12:58:21 +02:00
845a48371f
RVRNEXT-33 adapt to new soko-web interfaces 2023-05-02 12:58:18 +02:00

17
web.php
View File

@ -4,6 +4,7 @@ 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 RVR\Controller\HomeController; use RVR\Controller\HomeController;
use RVR\Controller\LoginController; use RVR\Controller\LoginController;
use RVR\Controller\OAuthAuthController; use RVR\Controller\OAuthAuthController;
@ -88,33 +89,23 @@ Container::$routeCollection->group('communities', function (RouteCollection $rou
}); });
}); });
Container::$sessionHandler = new DatabaseSessionHandler(Container::$dbConnection); Container::$sessionHandler = new DatabaseSessionHandler(Container::$dbConnection, 'sessions', new DateTime('-1 minute'));
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' => 604800, 'cookie_lifetime' => 0,
'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'
]);
}
Container::$request = new Request( Container::$request = new Request(
$_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'],
$_GET, $_GET,
$_POST, $_POST,
getallheaders(), getallheaders(),
$_SESSION, new Session($_SESSION),
new UserRepository() new UserRepository()
); );