title: laravel 5 set Database with parameters from Session
body: <p>I'm building an app where different users are accessing different databases. </p>
  
  <p>In laravel 4, it was as easy as defining the database connection like so:</p>
  
  <pre><code>    'usertable' =&gt; [
          'driver'    =&gt; 'mysql',
          'host'      =&gt; env('DB_HOST'),
          'database'  =&gt; Session::get('table'), &lt;&lt; works for laravel 4
          'username'  =&gt; env('DB_USERNAME'),
          'password'  =&gt; env('DB_PASSWORD'),
          'charset'   =&gt; 'utf8',
          'collation' =&gt; 'utf8_unicode_ci',
          'prefix'    =&gt; '',
          'strict'    =&gt; false,
      ],
  </code></pre>
  
  <p>However, laravel 5 throws an error:</p>
  
  <blockquote>
    <p>Class 'Session' not found in ...</p>
  </blockquote>
  
  <p>I have tried to import Session in multiple ways and with every namespace I have found which could be Session's namespace, but nothing works at all and the error persists. </p>
  
  <p>It seems like laravel5 would load the database class with all the possible connections before the Session class is autoloaded.</p>
  
  <p>Is there another way to create database connections for different users? Or can someone suggest another way to do so?</p>