當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。