mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix missing expiry times on cookies.
When writing multiple cookies in a single request with the default expiry time, cookies after the first should continue to have the default expiry time used. Fixes #3965
This commit is contained in:
parent
3f186d6c97
commit
9efad54e31
2 changed files with 19 additions and 1 deletions
|
@ -421,7 +421,7 @@ class CookieComponent extends Component {
|
|||
'httpOnly' => $this->httpOnly
|
||||
));
|
||||
|
||||
if (!is_null($this->_reset)) {
|
||||
if (!empty($this->_reset)) {
|
||||
$this->_expires = $this->_reset;
|
||||
$this->_reset = null;
|
||||
}
|
||||
|
|
|
@ -203,6 +203,24 @@ class CookieComponentTest extends CakeTestCase {
|
|||
$this->assertEquals('value', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that two write() calls use the expiry.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWriteMultipleShareExpiry() {
|
||||
$this->Cookie->write('key1', 'value1', false);
|
||||
$this->Cookie->write('key2', 'value2', false);
|
||||
|
||||
$name = $this->Cookie->name . '[key1]';
|
||||
$result = $this->Controller->response->cookie($name);
|
||||
$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong');
|
||||
|
||||
$name = $this->Cookie->name . '[key2]';
|
||||
$result = $this->Controller->response->cookie($name);
|
||||
$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong');
|
||||
}
|
||||
|
||||
/**
|
||||
* test write with distant future cookies
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue