Hi All,
I got the following problem. I got a class that handles my messages(succes, error, notices, warnings, blabla) to my template parser which puts them in the header.php
In this case after logging in and before redirecting to a new page it sends a message to the message class. Thereafter the user is redirected to the new page. The destructor of the message class puts the messages array into a session var.
Upon loading the new page the message class contructor retrieves the messages from the session and is supposed to clear the sessions vars so that it only shows one time when the give_succes_messages method is called and on the next page they should be gone.
Guess what happens, the message keeps returning every time I go to a other page and NOT calling the new message method again.
If I put a print_r on the session var and the variable in the class(which I temporarily made public instead of private) anywhere in the page it says its empty but when the new page is loaded it's there again.
How could this possibly happen?
The code:
class.php
//set the registry
public function __construct($registry)
{
$this->registry = $registry;
//retrieve succes messages
$this->succes_messages = $_SESSION['succes_messages'];
$_SESSION['succes_messages'] = array();
//retrieve fail messages
$this->fail_messages = $_SESSION['fail_messages'];
$_SESSION['fail_messages'] = array();
}
//retrieve succes messages
public function give_succes_messages()
{
$temp = $this->succes_messages;
$this->succes_messages = array();
return $temp;
}
//destructor saves the messages for the template in a session variable
public function __destruct()
{
$_SESSION['succes_messages'] = $this->succes_messages;
$_SESSION['fail_messages'] = $this->fail_messages;
}