Skip to content

Commit 7cb875a

Browse files
authored
Merge pull request #3 from leafsphp/fix-session-start
FIX: Prevent session start if session already started
2 parents 3256a7c + 232fceb commit 7cb875a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test
22
Experimental
33
vendor
4-
composer.lock
4+
composer.lock
5+
.idea

src/CSRF.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CSRF extends Anchor
1818

1919
/**
2020
* Manage config for leaf anchor
21-
*
21+
*
2222
* @param array|null $config The config to set
2323
*/
2424
public static function config($config = null)
@@ -32,8 +32,10 @@ public static function config($config = null)
3232

3333
public static function init()
3434
{
35-
session_start();
36-
35+
if (session_status() !== PHP_SESSION_ACTIVE) {
36+
session_start();
37+
}
38+
3739
if (!isset($_SESSION[static::$config["SECRET_KEY"]])) {
3840
Session::set(static::$config["SECRET_KEY"], static::generateToken());
3941
}

0 commit comments

Comments
 (0)