当前位置: 首页>>代码示例>>PHP>>正文


PHP Cookie::getName方法代码示例

本文整理汇总了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;
 }
开发者ID:conformity,项目名称:http-message,代码行数:45,代码来源:CookieTrait.php

示例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()));
     }
 }
开发者ID:jivoo,项目名称:http,代码行数:15,代码来源:CookiePool.php

示例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());
 }
开发者ID:seytar,项目名称:psx,代码行数:9,代码来源:CookieTest.php

示例4: clearCookie

 /**
  * @param Cookie $cookie
  */
 public function clearCookie(Cookie $cookie)
 {
     $cookie->setExpire(1);
     $this->cookies[$cookie->getName()] = $cookie;
 }
开发者ID:cawaphp,项目名称:cawa,代码行数:8,代码来源:HttpTrait.php

示例5: addCookie

 public function addCookie(Cookie $cookie)
 {
     $this->cookies[$cookie->getName()] = $cookie;
 }
开发者ID:timesplinter,项目名称:tsfw-http,代码行数:4,代码来源:HttpResponse.php

示例6: set

 /**
  * Sets a cookie.
  *
  * @param Symfony\Components\BrowserKit\Cookie $cookie A Cookie instance
  */
 public function set(Cookie $cookie)
 {
     $this->cookieJar[$cookie->getName()] = $cookie;
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:9,代码来源:CookieJar.php

示例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;
 }
开发者ID:rouffj,项目名称:symfony,代码行数:11,代码来源:CookieJar.php

示例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;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:12,代码来源:HttpScriptletRequest.class.php

示例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;
 }
开发者ID:christophercutts,项目名称:tech-test,代码行数:12,代码来源:HttpResponse.php

示例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';
 }
开发者ID:symfony,项目名称:symfony,代码行数:10,代码来源:ResponseHeaderBag.php

示例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()]);
 }
开发者ID:amphp,项目名称:artax,代码行数:10,代码来源:ArrayCookieJar.php

示例12: get

 /**
  * Get cookie.
  */
 public function get(Cookie $cookie)
 {
     return $_COOKIE[$cookie->getName()];
 }
开发者ID:reshadf,项目名称:RMProject,代码行数:7,代码来源:CookieStorage.php

示例13: assertCookieNameAndValue

 private function assertCookieNameAndValue(Cookie $cookie, $expectedName, $expectedValue)
 {
     $this->assertEquals($expectedName, $cookie->getName());
     $this->assertEquals($expectedValue, $cookie->getValue());
 }
开发者ID:philsam,项目名称:dflydev-fig-cookies,代码行数:5,代码来源:CookieTest.php

示例14: add

 public function add(Cookie $cookie)
 {
     $this->cookies[$cookie->getName()] = $cookie;
     return $this;
 }
开发者ID:phpf,项目名称:http,代码行数:5,代码来源:CookieJar.php

示例15: with

 /**
  * @param Cookie $cookie
  * @return Cookies
  */
 public function with(Cookie $cookie)
 {
     $clone = clone $this;
     $clone->cookies[$cookie->getName()] = $cookie;
     return $clone;
 }
开发者ID:philsam,项目名称:dflydev-fig-cookies,代码行数:10,代码来源:Cookies.php


注:本文中的Cookie::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。