0

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?

Dawiss
  • 65
  • 1
  • 11

1 Answers1

1

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.

Dirk McQuickly
  • 2,099
  • 1
  • 17
  • 19
  • Thank you, that solved this problem. But it appears to increment the value by 3 not by 1, which is kind a weird. When was echoing values before and after the increment function it still shows that it is executed only once. – Dawiss Oct 27 '13 at 12:24