Clean up to use session methods and not _SESSION directly

Add session_unset for unsetAll and rename this method to "clear"
This commit is contained in:
Clemens Schwaighofer
2024-12-05 13:25:08 +09:00
parent 075fe967d5
commit e57c336dba
6 changed files with 32 additions and 20 deletions

View File

@@ -294,11 +294,15 @@ class Session
* - unset session_name and session_id internal vars
* - destroy session
*
* @return bool
* @return bool True on successful session destroy
*/
public function sessionDestroy(): bool
{
$this->unsetAll();
// abort to false if not unsetable
if (!session_unset()) {
return false;
}
$this->clear();
if (
ini_get('session.use_cookies') &&
!ini_get('session.use_strict_mode')
@@ -331,9 +335,12 @@ class Session
*
* @return void
*/
public function unsetAll(): void
public function clear(): void
{
$this->restartSession();
if (!session_unset()) {
throw new \RuntimeException('[SESSION] Cannot unset session vars', 1);
}
if (!empty($_SESSION)) {
$_SESSION = [];
}