本文整理汇总了PHP中Zend_Http_Cookie::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Cookie::factory方法的具体用法?PHP Zend_Http_Cookie::factory怎么用?PHP Zend_Http_Cookie::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Cookie
的用法示例。
在下文中一共展示了Zend_Http_Cookie::factory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsSecure
public function testIsSecure()
{
foreach ($this->secureTests as $cookieStr) {
$cookie = Zend_Http_Cookie::factory($cookieStr);
$this->assertTrue($cookie->isSecure());
}
foreach ($this->nonSecureTests as $cookieStr) {
$cookie = Zend_Http_Cookie::factory($cookieStr);
$this->assertFalse($cookie->isSecure());
}
}
示例2: addCookie
/**
* Add a cookie to the jar. Cookie should be passed either as a Zend_Http_Cookie object
* or as a string - in which case an object is created from the string.
*
* @param Zend_Http_Cookie|string $cookie
* @param Zend_Uri_Http|string $red_uri Optional reference URI (for domain, path, secure)
*/
public function addCookie($cookie, $ref_uri = null)
{
if (is_string($cookie)) {
$cookie = Zend_Http_Cookie::factory($cookie, $ref_uri);
}
if ($cookie instanceof Zend_Http_Cookie) {
$domain = $cookie->getDomain();
$path = $cookie->getPath();
if (!isset($this->cookies[$domain])) {
$this->cookies[$domain] = array();
}
if (!isset($this->cookies[$domain][$path])) {
$this->cookies[$domain][$path] = array();
}
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
} else {
throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object');
}
}
示例3: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
*/
public function setCookie($cookie, $value = null)
{
if (!is_null($value)) {
$value = urlencode($value);
}
if (isset($this->Cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->Cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && !is_null($value)) {
if (preg_match("/[=,; \t\r\n\v\f]/", $cookie)) {
throw new Zend_Http_Exception("Cookie name cannot contain these characters: =,; \t\r\n\v\f ({$name})");
}
$cookie = Zend_Http_Cookie::factory("{$cookie}={$value}", $this->uri);
$this->Cookiejar->addCookie($cookie);
}
} else {
parent::setCookie($cookie, $value);
}
}
示例4: setCookie
/**
* Add a cookie to the request. If the client has no Cookie Jar, the cookies
* will be added directly to the headers array as "Cookie" headers.
*
* @param Zend_Http_Cookie|string $cookie
* @param string|null $value If "cookie" is a string, this is the cookie value.
* @return Zend_Http_Client
*/
public function setCookie($cookie, $value = null)
{
if ($value !== null) {
$value = urlencode($value);
}
if (isset($this->Cookiejar)) {
if ($cookie instanceof Zend_Http_Cookie) {
$this->Cookiejar->addCookie($cookie);
} elseif (is_string($cookie) && $value !== null) {
$cookie = Zend_Http_Cookie::factory("{$cookie}={$value}", $this->uri);
$this->Cookiejar->addCookie($cookie);
}
} else {
if ($cookie instanceof Zend_Http_Cookie) {
$cookie = $cookie->getName();
$value = $cookie->getValue();
}
if (preg_match("/[=,; \t\r\n\v\f]/", $cookie)) {
throw new Zend_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\v\f ({$name})");
}
$value = urlencode($value);
$this->setHeaders('cookie', "{$cookie}={$value}", false);
}
return $this;
}