Hi,
I'm having a bizarre problem with a project I'm working on. Basically, on completion of certain functions I need to display a message to the user on the next page they visit, so I have a function which sets a session variable with the message text. Then, on page load, there is another function which checks if this has been set, and if so displays the message and unsets the session variable.
The problem I'm having is that on some pages, despite the session variable being unset, the message keeps appearing until I log out/clear the session completely. I've tried dumping the session and the variable is definitely being unset in the right place. I have no idea why this should be happening, and Googling didn't turn up anything useful.
Has anyone encountered anything similar to this, and if so - any tips for solving it?
Thanks in advance (from me and my sanity!)
A (simplified) example of the code in question:
function flash($strMessage) {
$_SESSION['message'] = $strMessage;
}
function showFlash() {
if(isset($_SESSION['message']) {
echo "<div class='flash'>{$_SESSION['message']}</div>";
unset($_SESSION['message']);
}
}