Skip to content

Commit fdfa886

Browse files
committed
Check if session is really active
If you started and stopped a PHP session then session_id won't be empty (but session is closed). If you use session_status you can get the real state of a PHP session.
1 parent 5c5a3e8 commit fdfa886

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/facebook.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ class Facebook extends BaseFacebook
5555
* @see BaseFacebook::__construct
5656
*/
5757
public function __construct($config) {
58-
if (!session_id()) {
59-
session_start();
58+
if (function_exists('session_status')) {
59+
if (session_status() !== PHP_SESSION_ACTIVE) {
60+
session_start();
61+
}
62+
} else {
63+
if (!session_id()) {
64+
session_start();
65+
}
6066
}
6167
parent::__construct($config);
6268
if (!empty($config['sharedSession'])) {

0 commit comments

Comments
 (0)