Fix session problem on 32 bit systems when using "stay logged in permanently" (fixes #278)

This commit is contained in:
Bernd Bestel 2019-06-08 16:47:45 +02:00
parent 9e7d62b62d
commit b1adaa24cf
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 2 additions and 2 deletions

View File

@ -30,7 +30,7 @@ class LoginController extends BaseController
if ($user !== null && password_verify($inputPassword, $user->password))
{
$sessionKey = $this->SessionService->CreateSession($user->id, $stayLoggedInPermanently);
setcookie($this->SessionCookieName, $sessionKey, intval(time() + 31220640000)); // Cookie expires in 999 years, but session validity is up to SessionService
setcookie($this->SessionCookieName, $sessionKey, PHP_INT_SIZE == 4 ? PHP_INT_MAX : PHP_INT_MAX>>32); // Cookie expires never, but session validity is up to SessionService
if (password_needs_rehash($user->password, PASSWORD_DEFAULT))
{

View File

@ -40,7 +40,7 @@ class SessionService extends BaseService
$expires = date('Y-m-d H:i:s', intval(time() + 2592000)); // Default is that sessions expire in 30 days
if ($stayLoggedInPermanently === true)
{
$expires = date('Y-m-d H:i:s', intval(time() + 31220640000)); // 999 years aka forever
$expires = date('Y-m-d H:i:s', PHP_INT_SIZE == 4 ? PHP_INT_MAX : PHP_INT_MAX>>32); // Never
}
$sessionRow = $this->Database->sessions()->createRow(array(