Hello you wonderful coders you.
I've been staring at this line of code (line 74 highlighted below) for a while in m_template.php, and want to share what it's doing.
function getAlerts()
{
$data = '';
foreach($this->alertTypes as $alert)
{
if (isset($_SESSION[$alert]))
{
foreach($_SESSION[$alert] as $value)
{
$data .= '<li class="'. $alert .'">' . $value . '</li>';
}
unset($_SESSION[$alert]);
}
}
return $data;
}
The unset is here so that the next time a user clicks the submit button, the $_SESSION variable will have a clean slate (at least as far as alerts are concerned). Otherwise, a user might click the submit button when they've entered valid information, and receive an error message in the members page.
I just commented out the unset line and ran the code. First I entered wrong information and clicked submit. So $_SESSION now has this in it "you entered an invalid username or password." Then, I entered valid information (so now $_SESSION should also have this in it "You successfully logged in to the members page"). When I did that, I was redirected to the members page. At the top were the alerts. There was an alert saying "You successfully logged in to the members page" and then the error: "you entered an invalid username or password."
Just thought others may have been confused like me about why that line of code is in there at all.