Esempio n. 1
0
 /**
  * 用户登录服务
  * 
  * @param UserForm $userInfo
  * @return boolean
  */
 public function login($userInfo)
 {
     $db = $this->_getConnecion();
     $stmt = $db->createStatement('SELECT * FROM user WHERE username=:username AND password =:password');
     if (!$stmt->getValue(array('username' => $userInfo->getUsername(), 'password' => $userInfo->getPassword()))) {
         return false;
     }
     return WindCookie::set($this->cookieName, $userInfo);
 }
Esempio n. 2
0
 /**
  * 设置cookie
  *
  * @param string $name cookie名称
  * @param string $value cookie值,默认为null
  * @param string|int $expires 过期时间,默认为null即会话cookie,随着会话结束将会销毁
  * @param string $pre cookie前缀,默认为null即没有前缀
  * @param boolean $httponly
  * @return boolean
  */
 public static function setCookie($name, $value = null, $expires = null, $httponly = false)
 {
     $domain = Wekit::C('site', 'cookie.domain');
     $path = Wekit::C('site', 'cookie.path');
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($name = $pre . '_' . $name);
     $expires && ($expires += self::getTime());
     return WindCookie::set($name, $value, false, $expires, $path, $domain, false, $httponly);
 }
Esempio n. 3
0
 public function saveToken($tokenName = '')
 {
     if (empty($this->token[$tokenName])) {
         $this->token[$tokenName] = $this->getToken($tokenName);
         if (empty($this->token[$tokenName])) {
             $this->token[$tokenName] = WindSecurity::generateGUID();
             WindCookie::set($tokenName, $this->token[$tokenName], false, null, null, null, false, true);
         }
     }
     return $this->token[$tokenName];
 }
 /**
  * 设置cookie
  * 
  * @param string $name
  * @param mixed $value
  * @param int|null $expires 过期时间
  * @return boolean
  */
 public function set($name, $value, $expires = null)
 {
     $this->prefix && ($name = $this->prefix . $name);
     return WindCookie::set($name, $value, $this->encode, $expires, $this->path, $this->domain, $this->secure, $this->httponly);
 }