I'm trying to set a session variable so a pop-up box only appears once per session.
To do this I've created a module that is called via AJAX when someone closes the popup. The module's controller sets a session variable. The controller looks like this:
class Company_Popup_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
Mage::getSingleton('core/session')->setNewsletterPopup('yes');
}
}
Super simple.
Then, in the block I check if the session variable is set (or if the user is logged in):
class Company_Popup_Block_Popup extends Mage_Core_Block_Template
{
public function displayPopup(){
if(!$this->helper('customer')->isLoggedIn() && Mage::getSingleton('core/session')->getNewsletterPopup() == null){
return true;
}
else{
return false;
}
}
public function getSessionData(){
return Mage::getSingleton('core/session');
}
}
The template file then calls the displayPopup method and either displays the newsletter popup or not.
It all works perfectly... until I turn on Cache at which point the session variable doesn't get set or at the least isn't accessible in the block / template file.
What have I missed here?