mirror of
https://github.com/grocy/grocy.git
synced 2025-10-12 16:44:55 +00:00
Added option to stay logged in permanently
This commit is contained in:
@@ -33,14 +33,20 @@ class SessionService extends BaseService
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function CreateSession($userId)
|
||||
public function CreateSession($userId, $stayLoggedInPermanently = false)
|
||||
{
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
|
||||
$expires = date('Y-m-d H:i:s', time() + 2592000); // Default is that sessions expire in 30 days
|
||||
if ($stayLoggedInPermanently === true)
|
||||
{
|
||||
$expires = date('Y-m-d H:i:s', time() + 31220640000); // 999 years aka forever
|
||||
}
|
||||
|
||||
$sessionRow = $this->Database->sessions()->createRow(array(
|
||||
'user_id' => $userId,
|
||||
'session_key' => $newSessionKey,
|
||||
'expires' => date('Y-m-d H:i:s', time() + 2592000) // Default is that sessions expire in 30 days
|
||||
'expires' => $expires
|
||||
));
|
||||
$sessionRow->save();
|
||||
|
||||
|
Reference in New Issue
Block a user