I've got a series of php pages that write a number of session variables, some of which I want to selectively delete. Using the following code I am getting Apache errors, although I have no problem if I comment out the line beginning unset.
Am I missing something, or should I be doing this another way ?
foreach ($_SESSION as $key=>$value) {
if(ereg("my_pattern", $key)) {
unset($_SESSION[$key]);
}
}
I know many people prefer to use preg_match, but thats not where this script is falling down. I can echo out $key and $value both before and after the ereg() so I know its finding exactly the session vars I want to delete. I tried using $_SESSION['$key'], but as I suspected that didn't help in the slightest.
Useful pointers very welcome, I suspect I'm missing something quite simple.
Blu.