Hi All,
I'm having an issue with the session:
////////////////////////////////////////////////
$auth = new Zend_Session_Namespace( 'auth' );
...
...
...
The Auth namespace above works well and so far, so good. Its values get
reloaded on subsequent page loads. Session is setup properly and it works.
However, getting another slice (page) of the session does not write it the
new slice back to the session to reload it on the next page load (the auth
slice still works fine). Hence, a new value is getting generated for each
page-load:
////////////////////////////////////////////////
if ( ! $value = getPage( $key )) // Always fails
{
$value = generatePageValue(); // And a new value is generated
setPage( $key, $value ); // Save to session (but it does not
get saved as it does not reload on next page)
}
////////////////////////////////////////////////
function getPage( $key )
////////////////////////////////////////////////
{
$page = new Zend_Session_Namespace( 'page' );
//
if ( isset( $page->$key ))
{
$key = $page->$key;
//
if ( isset( $key[ 'value' ] )
return $key[ 'value' ]
}
//
return '';
}
////////////////////////////////////////////////
function setPage( $key, $value )
////////////////////////////////////////////////
{
$page = new Zend_Session_Namespace( 'page' );
$data = ( isset( $page->$key ) ? $page->$key : array());
//
$data[ 'value' ] = $value;
$page->$key = $data;
}
In the above 'page' namespace, it is always returning an empty value on
getPage() and hence saving a new value to the session on every page load. We
even tried the Zend_Session_Namespace::SINGLE_INSTANCE mode, too but no
luck. Here is the old code that used to work well without a problem:
////////////////////////////////////////////////
function getPage( $key )
////////////////////////////////////////////////
{
if ( isset( $_SESSION[ 'page' ][ $key ][ 'value' ] ))
return $_SESSION[ 'page' ][ $key ][ 'value' ];
//
return '';
}
////////////////////////////////////////////////
function setPage( $key, $value )
////////////////////////////////////////////////
{
$_SESSION[ 'page' ][ $key ][ 'value' ] = $value;
}
Any session *experts *out there who can help me with the above issue?
TIA