当前位置: 首页>>代码示例>>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;未经允许,请勿转载。