/** * Sets a cookie expire time to remove cookie value * * @param string $name Name of cookie * @return void */ protected function _delete($name) { $this->_response->cookie(array('name' => $this->name . $name, 'value' => '', 'expire' => time() - 42000, 'path' => $this->path, 'domain' => $this->domain, 'secure' => $this->secure, 'httpOnly' => $this->httpOnly)); }
/** * Test cookie setting * * @return void */ public function testCookieSettings() { $response = new CakeResponse(); $cookie = array('name' => 'CakeTestCookie[Testing]'); $response->cookie($cookie); $expected = array('name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false); $result = $response->cookie('CakeTestCookie[Testing]'); $this->assertEquals($expected, $result); $cookie = array('name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'secure' => true); $response->cookie($cookie); $expected = array('CakeTestCookie[Testing]' => array('name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false), 'CakeTestCookie[Testing2]' => array('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 = array('CakeTestCookie[Testing]' => array('name' => 'CakeTestCookie[Testing]', 'value' => 'test', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false), 'CakeTestCookie[Testing2]' => array('name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'domain' => '', 'secure' => true, 'httpOnly' => false)); $result = $response->cookie(); $this->assertEquals($expected, $result); }