devinemke wrote:because you are telling it to. you are unsetting every numerated array index in your for loop. i still don't undertand what you are ultimately trying to do here. what do you wish to unset?
I also don't fully understand what Benny007 is trying to do, however, Benny007 is not unsetting every array index devinemke.
Benny007's unset line is this:
unset($_SESSION['idx']);
That doesn't even use the $idx variable and even if it had the dollar sign, it's inside single quotes and it's value wouldn't get parsed out. So, it's just unsetting an index called 'idx' which probably doesn't even exist.
Benny007, figure out which index(es) you want to unset and use this sample syntax:
unset($_SESSION[0]); // removes index zero as an example!
By having a loop and putting the unset() within the index loop, will unset all the corresponding indexes. This will delete them all:
for ($idx = 0, $num_elements = count ($SESSION); $idx < $num_elements; ++$idx){
unset($SESSION[$idx]); // Use $idx variable!
}
But if you have nothing else stored in $_SESSION, then you can simply do:
$_SESSION = array();
to delete all values all at once.
hth.