本文整理匯總了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"));
}