A THttpCookie instance stores a single cookie, including the cookie name, value, domain, path, expire, and secure.
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Prado\TComponent
Esempio n. 1
0
 public function testSetSecure()
 {
     $cookie = new THttpCookie('name', 'value');
     $cookie->setSecure(true);
     self::assertTrue($cookie->getSecure());
 }
Esempio n. 2
0
 /**
  * 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;
     }
 }