diff --git a/inc/user.php b/inc/user.php index 91c34e5..752d6d9 100644 --- a/inc/user.php +++ b/inc/user.php @@ -7,7 +7,7 @@ class User extends PhpObject { //Cookie const COOKIE_ID_USER = 'subscriber'; - + const COOKIE_DURATION = 60 * 60 * 24 * 365; //1 year /** * Database Handle * @var Db @@ -56,7 +56,7 @@ class User extends PhpObject { //Set Cookie (valid 1 year) if($bSuccess) { $this->setUserId($iUserId); - $this->updateCookie(); + $this->updateCookie(self::COOKIE_DURATION); } return Spot::getResult($bSuccess, $sDesc); @@ -71,6 +71,7 @@ class User extends PhpObject { if($iUserId==0) $sDesc = 'lang:error_commit_db'; else { $sDesc = 'lang:nl_unsubscribed'; + $this->updateCookie(-60 * 60); //Set Cookie in the past, deleting it $bSuccess = true; } } @@ -88,7 +89,7 @@ class User extends PhpObject { $this->setUserId($_COOKIE[self::COOKIE_ID_USER]); //Extend cookie life - if($this->iUserId > 0) $this->updateCookie(); + if($this->iUserId > 0) $this->updateCookie(self::COOKIE_DURATION); } } @@ -121,7 +122,7 @@ class User extends PhpObject { return $this->oDb->selectRows($asInfo); } - private function updateCookie() { - setcookie(self::COOKIE_ID_USER, $this->iUserId, time() + 60 * 60 * 24 * 365); + private function updateCookie($iDeltaTime) { + setcookie(self::COOKIE_ID_USER, ($iDeltaTime < 0)?'':$this->iUserId, time() + $iDeltaTime); } } \ No newline at end of file