Skip to content

Commit

Permalink
Added back setRememberMeInactive and replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiuBota1 committed Feb 8, 2023
1 parent 8b6df5f commit 679d95f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "~8.1.0",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"psr/http-message": "^1.0.1",
"laminas/laminas-servicemanager": "^3.11.1",
"laminas/laminas-session": "^2.12.1",
Expand Down
1 change: 0 additions & 1 deletion src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Dot\Session;

use Dot\Session\Factory\AutoLoginMiddlewareFactory;
use Dot\Session\Factory\ContainerAbstractServiceFactory;
use Dot\Session\Factory\SessionMiddlewareFactory;
use Dot\Session\Factory\SessionOptionsFactory;
Expand Down
8 changes: 8 additions & 0 deletions src/Options/SessionOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ public function getRememberMeInactive(): int
{
return $this->rememberMeInactive;
}

/**
* @param int $rememberMeInactive
*/
public function setRememberMeInactive(int $rememberMeInactive)
{
$this->rememberMeInactive = $rememberMeInactive;
}
}
6 changes: 3 additions & 3 deletions src/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public function __construct(
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$now = time();
if (isset($_SESSION['LAST_ACTIVITY'])
&& $now - $_SESSION['LAST_ACTIVITY'] > $this->options->getRememberMeInactive()
if (isset($this->defaultSessionManager->getStorage()['LAST_ACTIVITY'])
&& $now - $this->defaultSessionManager->getStorage()['LAST_ACTIVITY'] > $this->options->getRememberMeInactive()
) {
$this->defaultSessionManager->destroy(['send_expire_cookie' => true, 'clear_storage' => true]);
$this->defaultSessionManager->start();
}
$_SESSION['LAST_ACTIVITY'] = $now;
$this->defaultSessionManager->getStorage()['LAST_ACTIVITY'] = $now;
return $handler->handle($request);
}
}

0 comments on commit 679d95f

Please sign in to comment.