(on Friday, 14 January 2011, 03:19 PM +0200):
> For the moment to retrieve a session stored variable you use something like
> this :
>
> 1. $defaultNamespace = new Zend_Session_Namespace('Default');
> 2.
> 3. if (isset <http://www.php.net/isset>($defaultNamespace->
> numberOfPageRequests)) {
> 4. // this will increment for each page load.
> 5. $defaultNamespace->numberOfPageRequests++;
> 6. } else {
> 7. $defaultNamespace->numberOfPageRequests = 1; // first time
> 8. }
> 9.
> 10. echo <http://www.php.net/echo> "Page requests this session: ",
> 11. $defaultNamespace->numberOfPageRequests;
>
>
>
> Maybe it be more convenient to provide additional accessor, something like
>
> $myDefaultLang = new Zend_Session_Namespace('Userpref', '
> SessionVO::defaultLanguageCode');
>
> to retrive the $_SESSION['Userpref']['SessionVO::defaultLanguageCode']
>
> The idea it be to store the session variables names as class constants(for
> some who like this, to avoid spelling errors) and to retrieve directly the
> variable.
That's something to do within your own application logic, but not
something we can enforce at the framework level.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
没有评论:
发表评论