From 39141e865b997a99f7f3b38bb2fd0d0a7a16031f Mon Sep 17 00:00:00 2001 From: Drak Date: Thu, 29 Mar 2012 18:02:06 +0545 Subject: [PATCH] [HttpFoundation] Add ability to force the lifetime (allows update of session cookie expiry-time) --- .../HttpFoundation/Session/Storage/MetaBag.php | 13 ++++++++----- .../Tests/Session/Storage/MetaBagTest.php | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetaBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetaBag.php index 4506687316..b2abcd8d68 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetaBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MetaBag.php @@ -80,9 +80,12 @@ class MetaBag implements SessionBagInterface return $this->meta['lifetime']; } - public function stampNew() + /** + * Stamps a new session's meta. + */ + public function stampNew($lifetime = null) { - $this->stampCreated(); + $this->stampCreated($lifetime); } /** @@ -134,10 +137,10 @@ class MetaBag implements SessionBagInterface $this->name = $name; } - private function stampCreated() + private function stampCreated($lifetime = null) { - $timeStamp = time();//(null === $timeStamp) ? time() : $timeStamp; + $timeStamp = time(); $this->meta['created'] = $this->meta['lastused'] = $this->lastUsed = $timeStamp; - $this->meta['lifetime'] = ini_get('session.cookie_lifetime'); + $this->meta['lifetime'] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime; } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetaBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetaBagTest.php index 45730e8aa7..a3b578c4cb 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetaBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetaBagTest.php @@ -96,5 +96,4 @@ class MetaBagTest extends \PHPUnit_Framework_TestCase { $this->bag->clear(); } - }