コード例 #1
0
 /**
  * Load the session from the datastore.
  *
  * @param string|NULL $sessionId  The ID of the session we should load, or NULL to use the default.
  * @return SimpleSAML_Session|NULL  The session object, or NULL if it doesn't exist.
  */
 public function loadSession($sessionId = NULL)
 {
     assert('is_string($sessionId) || is_null($sessionId)');
     if ($sessionId === NULL) {
         $sessionId = $this->session_id;
     }
     $session = $this->store->get('session', $sessionId);
     if ($session !== NULL) {
         assert('$session instanceof SimpleSAML_Session');
         return $session;
     }
     if (!$this->store instanceof SimpleSAML_Store_Memcache) {
         return NULL;
     }
     /* For backwards compatibility, check the MemcacheStore object. */
     $store = SimpleSAML_MemcacheStore::find($this->session_id);
     if ($store === NULL) {
         return NULL;
     }
     $session = $store->get('SimpleSAMLphp_SESSION');
     if ($session === NULL) {
         return NULL;
     }
     assert('is_string($session)');
     $session = unserialize($session);
     assert('$session instanceof SimpleSAML_Session');
     return $session;
 }
コード例 #2
0
 protected function __construct()
 {
     /* Call parent constructor to allow it to configure the session
      * id.
      */
     parent::__construct();
     /* Load the session object if it already exists. */
     $this->store = SimpleSAML_MemcacheStore::find($this->session_id);
     if ($this->store === NULL) {
         /* We didn't find the session. This may be because the
          * session has expired, or it could be because this is
          * a new session. In any case we create a new session.
          */
         $this->store = new SimpleSAML_MemcacheStore($this->session_id);
     }
 }