Skip to content

Commit 39141e8

Browse files
author
Drak
committed
[HttpFoundation] Add ability to force the lifetime (allows update of session cookie expiry-time)
1 parent ec3f88f commit 39141e8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/MetaBag.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ public function getLifetime()
8080
return $this->meta['lifetime'];
8181
}
8282

83-
public function stampNew()
83+
/**
84+
* Stamps a new session's meta.
85+
*/
86+
public function stampNew($lifetime = null)
8487
{
85-
$this->stampCreated();
88+
$this->stampCreated($lifetime);
8689
}
8790

8891
/**
@@ -134,10 +137,10 @@ public function setName($name)
134137
$this->name = $name;
135138
}
136139

137-
private function stampCreated()
140+
private function stampCreated($lifetime = null)
138141
{
139-
$timeStamp = time();//(null === $timeStamp) ? time() : $timeStamp;
142+
$timeStamp = time();
140143
$this->meta['created'] = $this->meta['lastused'] = $this->lastUsed = $timeStamp;
141-
$this->meta['lifetime'] = ini_get('session.cookie_lifetime');
144+
$this->meta['lifetime'] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
142145
}
143146
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetaBagTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,4 @@ public function testClear()
9696
{
9797
$this->bag->clear();
9898
}
99-
10099
}

0 commit comments

Comments
 (0)