Yes, this would be true--the code I posted is a snippet and not the entire
init()--I have code which checks if the string var is set to avoid the
problem you note.

Turns out that this issue is a PHP5 "feature" I overlooked where strings
(and all scalars?) are assigned by value by objects are assigned by
reference...problem solve, my bad.



Giuliano Riccio wrote:
> 
> You are setting your string variable to "top" in the session namespace
> everytime you request that controller, that's probably why.
> 
> spaceage wrote:
>> 
>> I should clarify that the string var does get (and persist) the initial
>> assignment of "top", but subsequent changes to the var doesn't
>> persist--the value can change within the action, but at the next
>> invocation of the action, the value of the string is still the initial
>> value ("top" in this case)...
>> 
>> ----------------------------------------
>> 
>> 
>> I'm having a strange issue with Zend_Session where I am assigning a
>> string and an object to the same Session Namespace.  The object will
>> persist, but the string won't...I open/start the namespace in init()
>> since I need access to the session data throughout my controller.  I then
>> assign the session data to a local var in my action for convenience.  Not
>> sure if the way I'm assigning vars is the problem, but in any case the
>> object is persisting and the string var isn't:
>> 
>> 
>> public function init() {
>>              //load session vars
>>              $this->sessionVars = new Zend_Session_Namespace('collection');
>> 
>>              //assign string to session as "activeAlbum"
>>              $this->sessionVars->activeAlbum =       "top";
>>              $this->activeAlbum =                            
>> $this->sessionVars->activeAlbum;
>> 
>>              //assign object "Album" to session as "currentAlbum"
>>              $this->sessionVars->currentAlbum =      new Album($name='top');
>>              $this->currentAlbum =                   
>> $this->sessionVars->currentAlbum;
>> }
>> 
>> public function listAction() {       
>>              //assign string to local var: DOESN'T PERSIST
>>              $currentAlbum = $this->currentAlbum;
>>              
>>              //assign Album object to local var: PERSISTS
>>              $activeAlbum = $this->activeAlbum;
>> 
>>                ....do stuff with $currentAlbum, $activeAlbum, but
>> $currentAlbum won't persist...
>> }
>> 
>> Any ideas?
>> 
>> 
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Session-oddity-tp21058169p21073158.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to