I try to build a simple refresh counter in the zend framework with zend_session_namespace, but it is not working as expected. I can’t call the namespace after it is set. In the examble below the code shows “1” again and again. Any advise for troubleshooting?
Zend_Session::start();
$defaultNamespace = new Zend_Session_Namespace('numbertester');
// Increment page views
if(isset($defaultNamespace->number)){
// The code is never entering here
$defaultNamespace->number++;
} else {
$defaultNamespace->number = 1;
}
echo $defaultNamespace->number;
UPDATE
I found this script to test the session config. When I run it on the server it end up in the last part and tells me, that my session config it incorrect. I am not sure what to do from here?
if( function_exists('ini_get') &&
in_array(strtolower(ini_get('session.save_handler')), array('user', 'users')) ) {
if( function_exists('ini_set') &&
false !== ini_set('session.save_handler', 'files') &&
false !== ini_set('session.save_path', APPLICATION_PATH . '/temporary/session/') ) {
if( !is_writable(APPLICATION_PATH . '/temporary/session/') ) {
throw new Exception('Please set full permissions on temporary/session (chmod 0777).');
}
} else {
throw new Exception('Your session configuration is incorrect and ' .
'could not be automatically corrected. Please set ' .
'session.save_handler=files and session.save_path=/tmp (or your ' .
'temporary directory on non-Linux OSes.');
}
}
May be your problem is somewhere else because I tested the code and its working on my side. For details please review this :
http://framework.zend.com/manual/1.12/en/zend.session.basic_usage.html