setExpire() public method

public setExpire ( $value )
コード例 #1
0
ファイル: THttpCookieTest.php プロジェクト: pradosoft/prado
 public function testSetExpire()
 {
     $cookie = new THttpCookie('name', 'value');
     $exp = time() + 3600;
     $cookie->setExpire($exp);
     self::assertEquals($exp, $cookie->getExpire());
 }
コード例 #2
0
ファイル: TAuthManager.php プロジェクト: pradosoft/prado
 /**
  * Logs in a user with username and password.
  * The username and password will be used to validate if login is successful.
  * If yes, a user object will be created for the application.
  * @param string username
  * @param string password
  * @param integer number of seconds that automatic login will remain effective. If 0, it means user logs out when session ends. This parameter is added since 3.1.1.
  * @return boolean if login is successful
  */
 public function login($username, $password, $expire = 0)
 {
     if ($this->_userManager->validateUser($username, $password)) {
         if (($user = $this->_userManager->getUser($username)) === null) {
             return false;
         }
         $this->updateSessionUser($user);
         $this->getApplication()->setUser($user);
         if ($expire > 0) {
             $cookie = new THttpCookie($this->getUserKey(), '');
             $cookie->setExpire(time() + $expire);
             $this->_userManager->saveUserToCookie($cookie);
             $this->getResponse()->getCookies()->add($cookie);
         }
         return true;
     } else {
         return false;
     }
 }