/** * Gets a cookie from the bag * * @param string $name * @return \Phalcon\Http\Cookie * @throws Exception */ public function get($name) { if (is_string($name) === false) { throw new Exception('The cookie name must be string'); } if (is_array($this->_cookies) === false) { $this->_cookies = array(); } if (isset($this->_cookies[$name]) === true) { return $this->_cookies[$name]; } //Create the cookie if it does not exist $cookie = new Cookie($name); $dependencyInjector = $this->_dependencyInjector; if (is_object($dependencyInjector) === true) { //Pass the DI to created cookies $cookie->setDi($dependencyInjector); //Enable encryption in the cookie if ($this->_useEncryption === true) { $cookie->useEncryption(true); } } $this->_cookies[$name] = $cookie; return $cookie; }
public function __toString() { return parent::__toString(); }
/** * @param \Phalcon\Http\Cookie $auth * @return Users */ public static function findByCookieAuth(\Phalcon\Http\Cookie $auth) { $data = explode('::', $auth->getValue()); return self::findFirst($data[1]); }