Question

I'm trying to work with Zend Sessions and after failing for a while, I tried basic counter example:

$defaultData = new Zend_Session_Namespace('language');
if(isset($defaultData->counter))
{
$defaultData->counter = 1;
} else {
$defaultData->counter++;
}
echo $defaultData->counter;

But on each page refresh I get the value 1. I'm calling Zen_Session::start in Bootstrap autoloader. What are the possible ways to debug, solve this problem?

Was it helpful?

Solution

Your if-else is the wrong way around. Now, if there is a session variable, you assign the value '1'. So, change statements for if and else and you will be fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top