Allow Seession settings to be changed

eg set the auto write + others
or set/unset can be chagned for single sets
This commit is contained in:
Clemens Schwaighofer
2024-12-20 18:48:00 +09:00
parent 7248906da7
commit d1e65c702e

View File

@@ -365,9 +365,10 @@ class Session
* @param bool $flag * @param bool $flag
* @return void * @return void
*/ */
public function setAutoWriteClose(bool $flag): void public function setAutoWriteClose(bool $flag): Session
{ {
$this->auto_write_close = $flag; $this->auto_write_close = $flag;
return $this;
} }
/** /**
@@ -515,12 +516,13 @@ class Session
* @param mixed $value value to set (can be anything) * @param mixed $value value to set (can be anything)
* @return void * @return void
*/ */
public function set(string $name, mixed $value): void public function set(string $name, mixed $value): Session
{ {
$this->checkValidSessionEntryKey($name); $this->checkValidSessionEntryKey($name);
$this->restartSession(); $this->restartSession();
$_SESSION[$name] = $value; $_SESSION[$name] = $value;
$this->closeSessionCall(); $this->closeSessionCall();
return $this;
} }
/** /**
@@ -579,7 +581,7 @@ class Session
* @param string $name _SESSION key name to remove * @param string $name _SESSION key name to remove
* @return void * @return void
*/ */
public function unset(string $name): void public function unset(string $name): Session
{ {
if (!isset($_SESSION[$name])) { if (!isset($_SESSION[$name])) {
return; return;
@@ -587,6 +589,7 @@ class Session
$this->restartSession(); $this->restartSession();
unset($_SESSION[$name]); unset($_SESSION[$name]);
$this->closeSessionCall(); $this->closeSessionCall();
return $this;
} }
/** /**