title: How to integrate CKFinder with Laravel?
body: <p>I'm trying to integrate CKFinder with Laravel, and I'm about 95% there. I can get everything to work, except for the <code>CheckAuthentication</code> function - I have to make it <code>return true</code> regardless for the upload to work.</p>
  
  <p>What I've tried doing is bootstrapping Laravel in the config.php file and then checking if a user is logged in, like below:</p>
  
  <p><em>public/packages/ckfinder/config.php</em></p>
  
  <pre><code>&lt;?php
  /*
   * ### CKFinder : Configuration File - Basic Instructions
   *
   * In a generic usage case, the following tasks must be done to configure
   * CKFinder:
   *     1. Check the $baseUrl and $baseDir variables;
   *     2. If available, paste your license key in the "LicenseKey" setting;
   *     3. Create the CheckAuthentication() function that enables CKFinder for authenticated users;
   *
   * Other settings may be left with their default values, or used to control
   * advanced features of CKFinder.
   */
  
  /** RIPPED FROM public/index.php **/
  
  /*
  |--------------------------------------------------------------------------
  | Register The Auto Loader
  |--------------------------------------------------------------------------
  |
  | Composer provides a convenient, automatically generated class loader
  | for our application. We just need to utilize it! We'll require it
  | into the script here so that we do not have to worry about the
  | loading of any our classes "manually". Feels great to relax.
  |
  */
  
  require __DIR__.'/../../../bootstrap/autoload.php';
  
  /*
  |--------------------------------------------------------------------------
  | Turn On The Lights
  |--------------------------------------------------------------------------
  |
  | We need to illuminate PHP development, so let's turn on the lights.
  | This bootstraps the framework and gets it ready for use, then it
  | will load up this application so that we can run it and send
  | the responses back to the browser and delight these users.
  |
  */
  
  $app = require __DIR__.'/../../../bootstrap/start.php';
  
  /** END public/index.php **/
  
  /**
   * This function must check the user session to be sure that he/she is
   * authorized to upload and access files in the File Browser.
   *
   * @return boolean
   */
  function CheckAuthentication()
  {
      // WARNING : DO NOT simply return "true". By doing so, you are allowing
      // "anyone" to upload and list the files in your server. You must implement
      // some kind of session validation here. Even something very simple as...
  
      return Auth::check();
  }
  </code></pre>
  
  <p>This always returns false, though. I've also tried directly using Laravel's <code>Session</code> to set a variable to true when someone logs in, and false when they log out, and then checking that in the config.php file, but it always returns the default value in <code>Session::get("IsAuthorized", false);</code>. Can anyone offer some guidance as to - </p>
  
  <p>1) How to authenticate whether the user should be allowed to upload?</p>
  
  <p>2) Why bootstrapping Laravel in another file seems to cause it to use a separate session, even when it's loading the same files?</p>