File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 */
You can’t perform that action at this time.
0 commit comments