File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public function __construct(
3636 $ sessionVariableName = 'lusitanian-oauth-token ' ,
3737 $ stateVariableName = 'lusitanian-oauth-state '
3838 ) {
39- if ($ startSession && !isset ( $ _SESSION )) {
39+ if ($ startSession && !$ this -> sessionHasStarted ( )) {
4040 session_start ();
4141 }
4242
@@ -185,4 +185,20 @@ public function __destruct()
185185 session_write_close ();
186186 }
187187 }
188+
189+ /**
190+ * Determine if the session has started.
191+ * @url http://stackoverflow.com/a/18542272/1470961
192+ * @return bool
193+ */
194+ protected function sessionHasStarted ()
195+ {
196+ // For more modern PHP versions we use a more reliable method.
197+ if (version_compare (PHP_VERSION , '5.4.0 ' ) >= 0 ) {
198+ return session_status () != PHP_SESSION_NONE ;
199+ }
200+
201+ // Below PHP 5.4 we should test for the current session ID.
202+ return session_id () !== '' ;
203+ }
188204}
You can’t perform that action at this time.
0 commit comments