当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Http_Cookie::factory方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:11,代码来源:CookieTest.php

示例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');
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:Cookiejar.php

示例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);
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:Client.php

示例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;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:Client.php


注:本文中的Zend_Http_Cookie::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。