當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cookie::validateCookieDomain方法代碼示例

本文整理匯總了PHP中Cookie::validateCookieDomain方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cookie::validateCookieDomain方法的具體用法?PHP Cookie::validateCookieDomain怎麽用?PHP Cookie::validateCookieDomain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cookie的用法示例。


在下文中一共展示了Cookie::validateCookieDomain方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testValidateCookieDomain

 /**
  * @dataProvider cookieDomains
  * @covers Cookie::validateCookieDomain
  */
 public function testValidateCookieDomain($expected, $domain, $origin = null)
 {
     if ($origin) {
         $ok = Cookie::validateCookieDomain($domain, $origin);
         $msg = "{$domain} against origin {$origin}";
     } else {
         $ok = Cookie::validateCookieDomain($domain);
         $msg = "{$domain}";
     }
     $this->assertEquals($expected, $ok, $msg);
 }
開發者ID:MediaWiki-stable,項目名稱:1.26.1,代碼行數:15,代碼來源:HttpTest.php

示例2: parseCookieResponseHeader

 /**
  * Parse the content of an Set-Cookie HTTP Response header.
  *
  * @param string $cookie
  * @param string $domain Cookie's domain
  * @return null
  */
 public function parseCookieResponseHeader($cookie, $domain)
 {
     $len = strlen('Set-Cookie:');
     if (substr_compare('Set-Cookie:', $cookie, 0, $len, true) === 0) {
         $cookie = substr($cookie, $len);
     }
     $bit = array_map('trim', explode(';', $cookie));
     if (count($bit) >= 1) {
         list($name, $value) = explode('=', array_shift($bit), 2);
         $attr = array();
         foreach ($bit as $piece) {
             $parts = explode('=', $piece);
             if (count($parts) > 1) {
                 $attr[strtolower($parts[0])] = $parts[1];
             } else {
                 $attr[strtolower($parts[0])] = true;
             }
         }
         if (!isset($attr['domain'])) {
             $attr['domain'] = $domain;
         } elseif (!Cookie::validateCookieDomain($attr['domain'], $domain)) {
             return null;
         }
         $this->setCookie($name, $value, $attr);
     }
 }
開發者ID:whysasse,項目名稱:kmwiki,代碼行數:33,代碼來源:Cookie.php

示例3: testValidateCookieDomain

 function testValidateCookieDomain()
 {
     $this->assertFalse(Cookie::validateCookieDomain("co.uk"));
     $this->assertFalse(Cookie::validateCookieDomain(".co.uk"));
     $this->assertFalse(Cookie::validateCookieDomain("gov.uk"));
     $this->assertFalse(Cookie::validateCookieDomain(".gov.uk"));
     $this->assertTrue(Cookie::validateCookieDomain("supermarket.uk"));
     $this->assertFalse(Cookie::validateCookieDomain("uk"));
     $this->assertFalse(Cookie::validateCookieDomain(".uk"));
     $this->assertFalse(Cookie::validateCookieDomain("127.0.0."));
     $this->assertFalse(Cookie::validateCookieDomain("127."));
     $this->assertFalse(Cookie::validateCookieDomain("127.0.0.1."));
     $this->assertTrue(Cookie::validateCookieDomain("127.0.0.1"));
     $this->assertFalse(Cookie::validateCookieDomain("333.0.0.1"));
     $this->assertTrue(Cookie::validateCookieDomain("example.com"));
     $this->assertFalse(Cookie::validateCookieDomain("example.com."));
     $this->assertTrue(Cookie::validateCookieDomain(".example.com"));
     $this->assertTrue(Cookie::validateCookieDomain(".example.com", "www.example.com"));
     $this->assertFalse(Cookie::validateCookieDomain("example.com", "www.example.com"));
     $this->assertTrue(Cookie::validateCookieDomain("127.0.0.1", "127.0.0.1"));
     $this->assertFalse(Cookie::validateCookieDomain("127.0.0.1", "localhost"));
 }
開發者ID:amjadtbssm,項目名稱:website,代碼行數:22,代碼來源:HttpTest.php


注:本文中的Cookie::validateCookieDomain方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。