本文整理汇总了PHP中Cookie::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Cookie::getName方法的具体用法?PHP Cookie::getName怎么用?PHP Cookie::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cookie
的用法示例。
在下文中一共展示了Cookie::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: withCookie
/**
* Add a cookie header to the response
*
* No need to have more classes for this, simply alter the headers to include the Set-Cookie: header.
*
* @param $name
* @param null $value
* @param null $expires
* @param null $path
* @param null $domain
* @param bool|false $secure
* @param bool|false $httpOnly
*
* @return Response
*/
public function withCookie($cookie, $value = '', $expires = null, $path = '/', $domain = null, $secure = false, $httpOnly = true)
{
//transform it into a cookie instance
if (!$cookie instanceof Cookie) {
$cookie = new Cookie($cookie, $value, $expires, $path, $domain, $secure, $httpOnly);
}
//save it in the cookies array
$this->cookies[$cookie->getName()] = $cookie;
$this->cookieNames[$cookie->getName()] = $cookie->getName();
//get current cookie headers
$cookieHeaders = $this->getHeader('Set-Cookie');
//get a response object without the cookies
$temp = $this->withoutHeader('Set-Cookie');
//replace if already set
$exists = false;
foreach ($cookieHeaders as $index => $cookieString) {
if (substr($cookieString, 0, strlen($cookie->getName()) + 1) === $cookie->getName() . '=') {
$cookieHeaders[$index] = (string) $cookie;
$exists = true;
break;
}
}
//append if not already set
if (false === $exists) {
$cookieHeaders[] = (string) $cookie;
}
$response = $temp->withHeader('Set-Cookie', $cookieHeaders);
//return new instance
return $response;
}
示例2: add
/**
* Add a cookie to the pool.
*
* @param Cookie $cookie A cookie.
*/
public function add(Cookie $cookie)
{
if ($cookie instanceof MutableCookie) {
$this->cookies[$cookie->getName()] = $cookie;
} elseif ($cookie instanceof ResponseCookie) {
$this[$cookie->getName()]->set($cookie->get())->setPath($cookie->getPath())->setDomain($cookie->getDomain())->setSecure($cookie->isSecure())->setHttpOnly($cookie->isHttpOnly())->expiresAt($cookie->getExpiration());
} else {
$this->cookies[$cookie->getName()] = $this->setDefaults(new MutableCookie($cookie->getName(), $cookie->get()));
}
}
示例3: testCookie
public function testCookie()
{
$cookie = new Cookie('DNR=deleted; expires=Tue, 24-Dec-2013 11:39:14 GMT; path=/; domain=.www.yahoo.com');
$this->assertEquals('DNR', $cookie->getName());
$this->assertEquals('deleted', $cookie->getValue());
$this->assertEquals(date('r', strtotime('Tue, 24-Dec-2013 11:39:14 GMT')), $cookie->getExpires()->format('r'));
$this->assertEquals('/', $cookie->getPath());
$this->assertEquals('www.yahoo.com', $cookie->getDomain());
}
示例4: clearCookie
/**
* @param Cookie $cookie
*/
public function clearCookie(Cookie $cookie)
{
$cookie->setExpire(1);
$this->cookies[$cookie->getName()] = $cookie;
}
示例5: addCookie
public function addCookie(Cookie $cookie)
{
$this->cookies[$cookie->getName()] = $cookie;
}
示例6: set
/**
* Sets a cookie.
*
* @param Symfony\Components\BrowserKit\Cookie $cookie A Cookie instance
*/
public function set(Cookie $cookie)
{
$this->cookieJar[$cookie->getName()] = $cookie;
}
示例7: set
/**
* Sets a cookie.
*
* @param Cookie $cookie A Cookie instance
*
* @api
*/
public function set(Cookie $cookie)
{
$this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
}
示例8: addCookie
/**
* Add cookie
*
* @param scriptlet.Cookie cookie
* @return scriptlet.Cookie added cookie
*/
public function addCookie(Cookie $cookie)
{
$this->initCookies();
$this->cookies[$cookie->getName()] = $cookie;
return $cookie;
}
示例9: deleteCookie
/**
* Deletes a cookie.
*
* @param Cookie $cookie
* @return void
*/
public function deleteCookie(Cookie $cookie)
{
$cookie->setValue('');
$cookie->setMaxAge(-1);
$this->cookies[$cookie->getName()] = $cookie;
}
示例10: setCookie
/**
* Sets a cookie.
*
* @param Cookie $cookie
*/
public function setCookie(Cookie $cookie)
{
$this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
$this->headerNames['set-cookie'] = 'Set-Cookie';
}
示例11: remove
/**
* Remove a specific cookie from storage
*
* @param Cookie $cookie
* @return void
*/
public function remove(Cookie $cookie)
{
unset($this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()]);
}
示例12: get
/**
* Get cookie.
*/
public function get(Cookie $cookie)
{
return $_COOKIE[$cookie->getName()];
}
示例13: assertCookieNameAndValue
private function assertCookieNameAndValue(Cookie $cookie, $expectedName, $expectedValue)
{
$this->assertEquals($expectedName, $cookie->getName());
$this->assertEquals($expectedValue, $cookie->getValue());
}
示例14: add
public function add(Cookie $cookie)
{
$this->cookies[$cookie->getName()] = $cookie;
return $this;
}
示例15: with
/**
* @param Cookie $cookie
* @return Cookies
*/
public function with(Cookie $cookie)
{
$clone = clone $this;
$clone->cookies[$cookie->getName()] = $cookie;
return $clone;
}