Zend Session

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend Session

documentatie alex
Hallo

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.


Best regards
Alex Petroni
Reply | Threaded
Open this post in threaded view
|

Re: Zend Session

weierophinney
Administrator
-- documentatie alex <[hidden email]> wrote
(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            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc