Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top