/** * Set cookie with httpCookieObject parameters * * @return bool If output exists prior to calling this function, * setcookie will fail and return false. If * setcookie successfully runs, it will return true. * This does not indicate whether the user accepted the cookie. */ public function write() { $name = $this->httpCookieObject->getName(); $value = $this->httpCookieObject->getValue(); $expire = $this->httpCookieObject->getExpiryTime(); $path = $this->httpCookieObject->getPath(); $domain = $this->httpCookieObject->getDomain(); $secure = $this->httpCookieObject->isSecure(); $this->value = $value; return @setcookie($name, $value, $expire, $path, $domain, $secure); }
/** * Make sure we get the correct value if it was set through the constructor * */ public function testGetValueConstructor() { $values = array('simpleCookie', 'space cookie', '!@#$%^*&()* ][{}?;', "line\n\rbreaks"); foreach ($values as $val) { $cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true); $this->assertEquals($val, $cookie->getValue()); } }
/** * Make sure we get the correct value if it was set through the constructor * * @param string $value * @dataProvider validCookieValueProvider */ public function testGetValueConstructor($val) { $cookie = new Zend_Http_Cookie('cookie', $val, 'example.com', time(), '/', true); $this->assertEquals($val, $cookie->getValue()); }