'Unsetting a $_SESSION with references
I am trying to unset a session from $_SESSION with the following function:
public function unsetSession($s) {
if (is_array($s)) {
$temp = &$_SESSION;
foreach ($s as $value) {
if (isset($temp[$value])) {
$temp = &$temp[$value];
}
else {
return false;
}
}
unset($temp);
return true;
}
}
I call it like this unsetSession(array("key1", "key2", "etc."));.
However, it doesn't work and the session will not be deleted. What am I missing?
Thank you in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
