當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。