0

After upgrading my Magento 2 I see this error message all the time I try to log in via the admin panel. The frontend pages are working fine.

Fatal error: Uncaught TypeError: strtotime() expects parameter 1 to be string, null given in /app/vendor/magento/module-security/Model/AdminSessionInfo.php:136 Stack trace: 
#0 /app/vendor/magento/module-security/Model/AdminSessionInfo.php(136): strtotime(NULL) 
#1 /app/vendor/magento/module-security/Model/AdminSessionInfo.php(119): Magento\Security\Model\AdminSessionInfo->isSessionExpired() 
#2 /app/vendor/magento/module-security/Model/AdminSessionInfo.php(108): Magento\Security\Model\AdminSessionInfo->checkActivity() 
#3 /app/vendor/magento/module-security/Model/Plugin/AuthSession.php(63): Magento\Security\Model\AdminSessionInfo->isLoggedInStatus() 

#4 /app/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Security\Model\Plugin\AuthSession->aroundProlong(Object(Magento\Backend\Model\Auth\Session\Interceptor), Object(Closure)) 
#5 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Backend\Model\Auth\Session\Interceptor->Magento\Framework\Interception\{closure}() 
#6 /app/generated/code/Ma in /app/vendor/magento/module-security/Model/AdminSessionInfo.php on line 136

How could I solve it?

2 Answers 2

2

issue in vendor/magento/module-security/Model/AdminSessionInfo.php you need to replace this

public function isSessionExpired()
{
$lifetime = $this->securityConfig->getAdminSessionLifetime();
$currentTime = $this->dateTime->gmtTimestamp();
$lastUpdatedTime = $this->getUpdatedAt();
if (!is_numeric($lastUpdatedTime)) {
    $lastUpdatedTime = strtotime($lastUpdatedTime);
}
return $lastUpdatedTime <= ($currentTime - $lifetime) ? true : false;
}

with

public function isSessionExpired()
{
$lifetime = $this->securityConfig->getAdminSessionLifetime();
$currentTime = $this->dateTime->gmtTimestamp();
$lastUpdatedTime = $this->getUpdatedAt();
if (!is_numeric($lastUpdatedTime)) {
    $lastUpdatedTime = $lastUpdatedTime === null ? 0 : strtotime($lastUpdatedTime);
}
return $lastUpdatedTime <= ($currentTime - $lifetime);
}
0

It's happening because of a function in the core expecting a string but receiving NULL from your DB table called admin_user_session.

It's already solved on Magento 2.4.4, but you can solve it in your outdated Magento running these commands.

Run this command so that new sessions will have the right parameter.

TRUNCATE admin_user_session;

Then improve your session limit too:

n98-magerun2 config:store:get system/security/max_session_size_admin 868000
1
  • Did not work. Is not resolved in 2.4.4 Commented Sep 7, 2022 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.