示例#1
0
 /**
  * Check that this cache instance is tracking the current user.
  */
 protected function check_tracked_user()
 {
     if (isset($_SESSION['USER']->id) && $_SESSION['USER']->id !== null) {
         // Get the id of the current user.
         $new = $_SESSION['USER']->id;
     } else {
         // No user set up yet.
         $new = 0;
     }
     if ($new !== self::$loadeduserid) {
         // The current user doesn't match the tracked userid for this request.
         if (!is_null(self::$loadeduserid)) {
             // Purge the data we have for the old user.
             // This way we don't bloat the session.
             $this->purge();
             // Update the session id just in case!
             $this->set_session_id();
         }
         self::$loadeduserid = $new;
         $this->currentuserid = $new;
     } else {
         if ($new !== $this->currentuserid) {
             // The current user matches the loaded user but not the user last used by this cache.
             $this->purge_current_user();
             $this->currentuserid = $new;
             // Update the session id just in case!
             $this->set_session_id();
         }
     }
 }