* [refac] Refactor the baseRouter::startSession() method to reuse web session in api mode.

This commit is contained in:
liugang
2025-12-02 16:31:42 +08:00
committed by sunhao
parent e9cf2e69d2
commit 49d863cba8
+2 -3
View File
@@ -1217,12 +1217,9 @@ class baseRouter
session_set_cookie_params(0, $this->config->webRoot, '', $this->config->cookieSecure, true);
if(!session_id()) session_start();
$this->sessionID = isset($ztSessionHandler) ? $ztSessionHandler->getSessionID() : session_id();
if(isset($_SERVER['HTTP_TOKEN'])) // If request header has token, use it as session for authentication.
{
helper::restartSession($_SERVER['HTTP_TOKEN']);
$this->sessionID = isset($ztSessionHandler) ? $ztSessionHandler->getSessionID() : session_id();
}
elseif(isset($_GET[$this->config->sessionVar]))
{
@@ -1232,6 +1229,8 @@ class baseRouter
helper::restartSession($_GET[$this->config->sessionVar]);
}
$this->sessionID = isset($ztSessionHandler) ? $ztSessionHandler->getSessionID() : session_id();
define('SESSION_STARTED', true);
}