I discovered a problem with the code with what I need it for.
If
$sizes or
$sizem or
$sizexl equal
0, then it removes the entire $_SESSION entity.
So if,
$sizes =
0 and
$sizem =
1 and
$sizexl =
3, then it will delete the entire entity from the session because
$sizes =
0.
I was looking for so it will delete the $_SESSION entity if only all the 'array attributes' equal 0.
I tried this but it didn't work:
PHP Code:
if (isset($_SESSION['cart']['content'][$_POST['id']]))
{
list($sizes, $sizem, $sizexl) = $_SESSION['cart']['content'][$_POST['id']];
if ($sizes == 0 & $sizem == 0 & $sizexl == 0)
{
unset($_SESSION['cart']['content'][$_POST['id']]);
}
}
I also tried:
PHP Code:
if ($sizes == 0 || $sizem == 0 || $sizexl == 0)
PHP Code:
if ($sizes || $sizem || $sizexl == 0)
PHP Code:
if ($sizes && $sizem && $sizexl == 0)
.. but no success.
I've actually got a solution (EDIT: it doesn't work, it just deletes everything!!!!!), but its a long and probably bad practice that would get me some funny stares lol, so wondering if anyone has a suggestion?
PHP Code:
if ($sizes == 0) {
if ($sizem == 0) {
if ($sizel == 0) {
// do delete;
}
}
}