Skip to content
Snippets Groups Projects
Commit 6a265f60 authored by Iwan Luijks's avatar Iwan Luijks Committed by Thijs Kinkhorst
Browse files

rememberme: Set cookie lifetime iso expire fixing the remember me feature and respective errors.

Currently the remember me functionality does not work correctly and using it results in severable undefined index errors as the expire cookie parameter is passed along the SessionHandlerPHP which does not accept this one. Using lifetime instead of expire, effectively doing the same thing, this can be fixed in a pretty simple way. Next to that the params given to the session handler are merged with the current ones before given to the session handler instead of after.
parent 952b6a64
No related branches found
No related tags found
No related merge requests found
......@@ -577,17 +577,17 @@ class Session implements Serializable, Utils\ClearableState
/**
* Set remember me expire time.
*
* @param int $expire Unix timestamp when remember me session cookies expire.
* @param int $lifetime Number of seconds after when remember me session cookies expire.
* @return void
*/
public function setRememberMeExpire(int $expire = null): void
public function setRememberMeExpire(int $lifetime = null): void
{
if ($expire === null) {
$expire = time() + self::$config->getInteger('session.rememberme.lifetime', 14 * 86400);
if ($lifetime === null) {
$lifetime = self::$config->getInteger('session.rememberme.lifetime', 14 * 86400);
}
$this->rememberMeExpire = $expire;
$this->rememberMeExpire = time() + $lifetime;
$cookieParams = ['expire' => $this->rememberMeExpire];
$cookieParams = ['lifetime' => $lifetime];
$this->updateSessionCookies($cookieParams);
}
......@@ -789,6 +789,7 @@ class Session implements Serializable, Utils\ClearableState
public function updateSessionCookies(array $params = []): void
{
$sessionHandler = SessionHandler::getSessionHandler();
$params = array_merge($sessionHandler->getCookieParams(), is_array($params) ? $params : []);
if ($this->sessionId !== null) {
$sessionHandler->setCookie($sessionHandler->getSessionCookieName(), $this->sessionId, $params);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment