Skip to content

Commit 0ae80a9

Browse files
committed
Merge branch 'chrisrowley14-master'
2 parents feca178 + 7bc9cd0 commit 0ae80a9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Session.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ public static function getPrefix()
5757
/**
5858
* If session has not started, start sessions.
5959
*
60+
* @param int $LifeTime → Lifetime of session in seconds
61+
*
6062
* @return bool
6163
*/
62-
public static function init()
64+
public static function init($lifeTime = 0)
6365
{
6466
if (self::$sessionStarted == false) {
65-
session_set_cookie_params(0);
67+
session_set_cookie_params($lifeTime);
6668
session_start();
6769

6870
return self::$sessionStarted = true;

tests/SessionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ public function testInit()
8686
$this->assertFalse($session::init());
8787
}
8888

89+
/**
90+
* Start session with a max lifetime.
91+
*
92+
* @runInSeparateProcess
93+
*/
94+
public function testInitLifeTime()
95+
{
96+
$session = $this->Session;
97+
98+
$this->assertTrue($session::init(10));
99+
$this->assertFalse($session::init(10));
100+
}
101+
89102
/**
90103
* Add value to a session.
91104
*/

0 commit comments

Comments
 (0)