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


PHP Response::cookie方法代码示例

本文整理汇总了PHP中Cake\Network\Response::cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::cookie方法的具体用法?PHP Response::cookie怎么用?PHP Response::cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Network\Response的用法示例。


在下文中一共展示了Response::cookie方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: assertCookie

 /**
  * Asserts cookie values
  *
  * @param string $expected The expected contents.
  * @param string $name The cookie name.
  * @param string $message The failure message that will be appended to the generated message.
  * @return void
  */
 public function assertCookie($expected, $name, $message = '')
 {
     if (empty($this->_response)) {
         $this->fail('Not response set, cannot assert cookies.');
     }
     $result = $this->_response->cookie($name);
     $this->assertEquals($expected, $result['value'], 'Cookie data differs. ' . $message);
 }
开发者ID:hossain-seaos,项目名称:cakephp,代码行数:16,代码来源:IntegrationTestCase.php

示例2: filterResponse

 /**
  * Filters the cake response to the BrowserKit one.
  *
  * @param \Cake\Network\Response $response Cake response.
  * @return \Symfony\Component\BrowserKit\Response BrowserKit response.
  */
 protected function filterResponse($response)
 {
     $this->cake['response'] = $response;
     foreach ($response->cookie() as $cookie) {
         $this->getCookieJar()->set(new Cookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']));
     }
     $response->sendHeaders();
     return new BrowserKitResponse($response->body(), $response->statusCode(), $response->header());
 }
开发者ID:cakephp,项目名称:codeception,代码行数:15,代码来源:Connector.php

示例3: assertCookieEncrypted

 /**
  * Asserts cookie values which are encrypted by the
  * CookieComponent.
  *
  * The difference from assertCookie() is this decrypts the cookie
  * value like the CookieComponent for this assertion.
  *
  * @param string $expected The expected contents.
  * @param string $name The cookie name.
  * @param string|bool $encrypt Encryption mode to use.
  * @param string|null $key Encryption key used. Defaults
  *   to Security.salt.
  * @param string $message The failure message that will be appended to the generated message.
  * @return void
  * @see \Cake\Utility\CookieCryptTrait::_encrypt()
  */
 public function assertCookieEncrypted($expected, $name, $encrypt = 'aes', $key = null, $message = '')
 {
     if (empty($this->_response)) {
         $this->fail('No response set, cannot assert cookies.');
     }
     $result = $this->_response->cookie($name);
     $this->_cookieEncriptionKey = $key;
     $result['value'] = $this->_decrypt($result['value'], $encrypt);
     $this->assertEquals($expected, $result['value'], 'Cookie data differs. ' . $message);
 }
开发者ID:aceat64,项目名称:cakephp,代码行数:26,代码来源:IntegrationTestCase.php

示例4: toCake

 /**
  * Convert a PSR7 Response into a CakePHP one.
  *
  * @param \Psr\Http\Message\ResponseInterface $response The response to convert.
  * @return \Cake\Network\Response The equivalent CakePHP response
  */
 public static function toCake(PsrResponse $response)
 {
     $body = static::getBody($response);
     $data = ['status' => $response->getStatusCode(), 'body' => $body['body']];
     $cake = new CakeResponse($data);
     if ($body['file']) {
         $cake->file($body['file']);
     }
     $cookies = static::parseCookies($response->getHeader('Set-Cookie'));
     foreach ($cookies as $cookie) {
         $cake->cookie($cookie);
     }
     $headers = static::collapseHeaders($response);
     $cake->header($headers);
     if (!empty($headers['Content-Type'])) {
         $cake->type($headers['Content-Type']);
     }
     return $cake;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:25,代码来源:ResponseTransformer.php

示例5: testCookieSettings

 /**
  * Test cookie setting
  *
  * @return void
  */
 public function testCookieSettings()
 {
     $response = new Response();
     $cookie = ['name' => 'CakeTestCookie[Testing]'];
     $response->cookie($cookie);
     $expected = ['name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false];
     $result = $response->cookie('CakeTestCookie[Testing]');
     $this->assertEquals($expected, $result);
     $cookie = ['name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'secure' => true];
     $response->cookie($cookie);
     $expected = ['CakeTestCookie[Testing]' => ['name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false], 'CakeTestCookie[Testing2]' => ['name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'domain' => '', 'secure' => true, 'httpOnly' => false]];
     $result = $response->cookie();
     $this->assertEquals($expected, $result);
     $cookie = $expected['CakeTestCookie[Testing]'];
     $cookie['value'] = 'test';
     $response->cookie($cookie);
     $expected = ['CakeTestCookie[Testing]' => ['name' => 'CakeTestCookie[Testing]', 'value' => 'test', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false], 'CakeTestCookie[Testing2]' => ['name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'domain' => '', 'secure' => true, 'httpOnly' => false]];
     $result = $response->cookie();
     $this->assertEquals($expected, $result);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:25,代码来源:ResponseTest.php

示例6: _delete

 /**
  * Sets a cookie expire time to remove cookie value.
  *
  * This is only done once all values in a cookie key have been
  * removed with delete.
  *
  * @param string $name Name of cookie
  * @return void
  */
 protected function _delete($name)
 {
     $config = $this->configKey($name);
     $expires = new Time('now');
     $this->_response->cookie(array('name' => $name, 'value' => '', 'expire' => $expires->format('U') - 42000, 'path' => $config['path'], 'domain' => $config['domain'], 'secure' => $config['secure'], 'httpOnly' => $config['httpOnly']));
 }
开发者ID:maitrepylos,项目名称:nazeweb,代码行数:15,代码来源:CookieComponent.php

示例7: _setCookie

 /**
  * Set the cookie in the response.
  *
  * Also sets the request->params['_csrfToken'] so the newly minted
  * token is available in the request data.
  *
  * @param \Cake\Network\Request $request The request object.
  * @param \Cake\Network\Response $response The response object.
  * @return void
  */
 protected function _setCookie(Request $request, Response $response)
 {
     $expiry = new Time($this->_config['expiry']);
     $value = hash('sha512', Security::randomBytes(16), false);
     $request->params['_csrfToken'] = $value;
     $response->cookie(['name' => $this->_config['cookieName'], 'value' => $value, 'expire' => $expiry->format('U'), 'path' => $request->webroot, 'secure' => $this->_config['secure'], 'httpOnly' => $this->_config['httpOnly']]);
 }
开发者ID:rlugojr,项目名称:cakephp,代码行数:17,代码来源:CsrfComponent.php

示例8: _setCookie

 /**
  * Set the cookie in the response.
  *
  * Also sets the request->params['_csrfToken'] so the newly minted
  * token is available in the request data.
  *
  * @param \Cake\Network\Request $request The request object.
  * @param \Cake\Network\Response $response The response object.
  * @return void
  */
 protected function _setCookie(Request $request, Response $response)
 {
     $value = Security::hash(Text::uuid(), 'sha1', true);
     $request->params['_csrfToken'] = $value;
     $response->cookie(['name' => $this->_config['cookieName'], 'value' => $value, 'expiry' => $this->_config['expiry'], 'path' => $request->webroot, 'secure' => $this->_config['secure']]);
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:16,代码来源:CsrfComponent.php

示例9: _delete

 /**
  * Sets a cookie expire time to remove cookie value
  *
  * @param string $name Name of cookie
  * @return void
  */
 protected function _delete($name)
 {
     $config = $this->config();
     $this->_response->cookie(array('name' => $config['name'] . $name, 'value' => '', 'expire' => time() - 42000, 'path' => $config['path'], 'domain' => $config['domain'], 'secure' => $config['secure'], 'httpOnly' => $config['httpOnly']));
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:11,代码来源:CookieComponent.php


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