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


PHP Cookie::fromString方法代码示例

本文整理汇总了PHP中Cookie::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Cookie::fromString方法的具体用法?PHP Cookie::fromString怎么用?PHP Cookie::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cookie的用法示例。


在下文中一共展示了Cookie::fromString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($storagePath)
 {
     if (!file_exists($storagePath)) {
         $cookieFileHandle = $this->createStorageFile($storagePath);
     } elseif (false === ($cookieFileHandle = @fopen($storagePath, 'r+'))) {
         throw new \RuntimeException('Failed opening cookie storage file for reading: ' . $storagePath);
     }
     while (!feof($cookieFileHandle)) {
         if ($line = fgets($cookieFileHandle)) {
             $cookie = Cookie::fromString($line);
             $this->store($cookie);
         }
     }
     $this->storagePath = $storagePath;
 }
开发者ID:PeeHaa,项目名称:Artax,代码行数:15,代码来源:FileCookieJar.php

示例2: updateFromSetCookie

 public function updateFromSetCookie(array $setCookies, $uri = null)
 {
     $cookies = array();
     foreach ($setCookies as $cookie) {
         foreach (explode(',', $cookie) as $i => $part) {
             if (0 === $i || preg_match('/^(?P<token>\\s*[0-9A-Za-z!#\\$%\\&\'\\*\\+\\-\\.^_`\\|~]+)=/', $part)) {
                 $cookies[] = ltrim($part);
             } else {
                 $cookies[count($cookies) - 1] .= ',' . $part;
             }
         }
     }
     foreach ($cookies as $cookie) {
         $this->set(Cookie::fromString($cookie, $uri));
     }
 }
开发者ID:phpsource,项目名称:pecl-caching-apc,代码行数:16,代码来源:CookieJar.php

示例3: updateFromResponse

 /**
  * Updates the cookie jar from a Response object.
  *
  * @param Symfony\Components\BrowserKit\Response $response A Response object
  * @param string                                 $url    The base URL
  */
 public function updateFromResponse(Response $response, $uri = null)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $cookie) {
         $this->set(Cookie::fromString($cookie), $uri);
     }
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:12,代码来源:CookieJar.php

示例4: set

    /**
     * {@inheritdoc}
     */
    public function set($key, $values, $replace = true)
    {
        $uniqueKey = str_replace('_', '-', strtolower($key));

        if ('set-cookie' === $uniqueKey) {
            if ($replace) {
                $this->cookies = array();
            }
            foreach ((array) $values as $cookie) {
                $this->setCookie(Cookie::fromString($cookie));
            }
            $this->headerNames[$uniqueKey] = $key;

            return;
        }

        $this->headerNames[$uniqueKey] = $key;

        parent::set($key, $values, $replace);

        // ensure the cache-control header has sensible defaults
        if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) {
            $computed = $this->computeCacheControlValue();
            $this->headers['cache-control'] = array($computed);
            $this->headerNames['cache-control'] = 'Cache-Control';
            $this->computedCacheControl = $this->parseCacheControl($computed);
        }
    }
开发者ID:symfony,项目名称:symfony,代码行数:31,代码来源:ResponseHeaderBag.php

示例5: getResponseCookies

 /**
  * Get HTTP response cookies
  *
  * @param $deleted boolean if true, get deleted cookies too
  * @return Cookie[]
  */
 public function getResponseCookies($deleted = true)
 {
     $cookies = [];
     foreach ($this->response_headers as $header) {
         $pos = strpos($header, ': ');
         if ($pos !== false) {
             $name = substr($header, 0, $pos);
             $value = substr($header, $pos + 2);
             if ($name == 'Set-Cookie') {
                 $cookie = new Cookie();
                 $cookie->fromString($value);
                 if ($deleted || !($cookie->value == 'deleted')) {
                     $cookies[] = $cookie;
                 }
             }
         }
     }
     return $cookies;
 }
开发者ID:TuxBoy,项目名称:Demo-saf,代码行数:25,代码来源:Proxy.php


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