Skip to content
taiwen edited this page Mar 14, 2013 · 1 revision

How to read and set session variables

  • Normal session:

    • Read a session variable: $readSessionVariable = $_SESSION['my_session'];

    • Write a session variable: $_SESSION['my_session'] = $mySessionData;

  • One-time session

      $session = Pi::service('session')->mySession;
      $session->setExpirationHops(1);
    
  • Variables with specific expiration

      $session = Pi::service('session')->mySession;
      $session->setExpirationSeconds(60);
    
Clone this wiki locally