本文整理汇总了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);
}
示例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);
}
}
示例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"));
}