I was thinking about doing it that way but it doesn't really seem like what
the registry is for. $_SESSION is already a singleton so it seems like it
just should be accessible. I'd almost rather just new a
Zend_Session_Namespace but that also seems really counterintuitive.
Maybe, I just should just stick with $_SESSION superglobal.
The project I'm working on is moving a php app to ZF. I've moved most of the
logic that doesn't require session variables but not sure how to proceed.
thanks,
-n
Pieter Kokx wrote:
>
> Hi,
>
> No, there isn't any way to do that. But you can use Zend_Registry to
> register some global classes.
>
> You can use it this way:
>
> $site_sess = new Zend_Session_Namespace('my_session');
>
> $site_sess->hello = 'what do you want?';
>
> Zend_Registry::set('site_sess', $site_sess);
>
> // in your controller:
> $site_sess = Zend_Registry::get('site_sess');
>
> Zend_Debug::dump($site_sess->hello);
>
> Mostly, I am using Zend_Registry for my configuration, but you can store
> any kind of data in it.
>
> river_jetties schreef:
>> I have a bootstrap file with the following:
>>
>> $site_sess=new Zend_Session_Namespace('my_session');
>> $site_sess->hello='what do you want?';
>>
>> I want to have session variables available throughout controllers and
>> model.
>> It seems like whenever I need to access them I need to do somethinkg like
>> the following in each controller function:
>>
>> public function homeAction(){
>> $site_sess=new Zend_Session_Namespace('my_session');
>> echo "<pre>\$site_sess:";
>> print_r($site_sess->hello);
>> echo "</pre>";
>> }
>>
>> Is there any way to just make $site_sess global to all models and
>> controllers via configuration? It seems like a lot of wasted typing.
>>
> --
> Regards,
>
> Pieter Kokx
> MaakSite.nl Productions
> PHP Developer
>
>
>
>
--
View this message in context:
http://www.nabble.com/making-Zend_Session-available-to-controller-model-functions-tp17460736p17461313.html
Sent from the Zend Framework mailing list archive at Nabble.com.