authentication : manage the state of session based on session_id() instead of isset ($_SESSION)

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4268 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-07-06 17:52:13 +00:00
parent 4459e9595d
commit 2c953b5428

View File

@@ -84,7 +84,7 @@ class authentication
*/ */
public function logout ($url = "") public function logout ($url = "")
{ {
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
if ($this->debug) echo "<pre>LOGOUT\n"; if ($this->debug) echo "<pre>LOGOUT\n";
$authsession = new \authsession (); $authsession = new \authsession ();
@@ -114,7 +114,7 @@ class authentication
public function pageHTML ($url = "") public function pageHTML ($url = "")
{ {
// If the user is already connected, redirect to the main page of the site // If the user is already connected, redirect to the main page of the site
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
$auth = new \auth (); $auth = new \auth ();
$pre = new \authparams (array ("session")); $pre = new \authparams (array ("session"));
@@ -138,7 +138,7 @@ class authentication
*/ */
public function verifAuthLoginPage ($url = "") public function verifAuthLoginPage ($url = "")
{ {
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
if ($this->debug) echo "Call verifAuthLoginPage ($url) : Start\n"; if ($this->debug) echo "Call verifAuthLoginPage ($url) : Start\n";
// rate-limit the connections // rate-limit the connections
@@ -365,7 +365,7 @@ class authentication
$this->route $this->route
->get ("authentication/logout({url})?", function ($url) use ($authObj) ->get ("authentication/logout({url})?", function ($url) use ($authObj)
{ {
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
$authObj->logout ($url); $authObj->logout ($url);
}) })
@@ -377,7 +377,7 @@ class authentication
->get ("authentication/({url})?", function ($url) use ($authObj) ->get ("authentication/({url})?", function ($url) use ($authObj)
{ {
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
$authObj->pageHTML ($url); $authObj->pageHTML ($url);
exit; exit;
@@ -385,7 +385,7 @@ class authentication
->post ("authentication/({url})?", function ($url) use ($authObj) ->post ("authentication/({url})?", function ($url) use ($authObj)
{ {
if (! isset ($_SESSION)) if (session_id () === "")
session_start (); session_start ();
$authObj->verifAuthLoginPage ($url); $authObj->verifAuthLoginPage ($url);
exit; exit;