Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      The Session

      Handling user sessions

      Table of Contents

      Introduction

      PHP brings a completed API to manage the session. However, Lion has his own session facade against the native PHP session by default.

      One of the main advantages of ussing the Lion session facade is to isolate session instances between application contexts. The other one is to have a session space to store context instances without interfering with other containers.

      Accessing the session

      The session can be accessed by calling the __Context::getSession() method. i.e.:

      1. <?php
      2.  
      3.     $session __ApplicationContext::getInstance()->getSession();

      The session exposes mainly the following methods:

      i.e.

      1. <?php
      2.  
      3.     //get the session:
      4.     $session __ApplicationContext::getInstance()->getSession();
      5.     //if a data already exists in session
      6.     if($session->hasData('data')) {
      7.         //get data from session
      8.         $data $session->getData('data');
      9.     }
      10.     else {
      11.         //retrieve data from database:
      12.         $data eg_retrieve_data_from_database();
      13.         //store data to session once, so next time won't be needed to
      14.         //get it from the database but from the session:
      15.         $session->setData('data'$data);
      16.     }