title: How to set a session variable before anything loads in Laravel?
body: <p>I want to set a session based on the URL (like <a href="http://de.domain.com" rel="nofollow">http://de.domain.com</a> or <a href="http://es.domain.com" rel="nofollow">http://es.domain.com</a>) before anything in Laravel loads and thought to do this in the <code>ConfigServiceProvider</code>:</p>
  
  <pre><code>public function boot() {
      // set language
      $parse = parse_url(url());
      $url_array = explode('.', $parse['host']);
      if($url_array[0] == 'domain' || $url_array[0] == 'www') {
          Session::put('current_language', Language::where('short', 'EN')-&gt;get());
          App::setLocale('en');
      } else {
          Session::put('current_language', Language::where('short', strtoupper($url_array[0]))-&gt;get());
          App::setLocale($url_array[0]);
      }
  }
  </code></pre>
  
  <p>But this is not working at all. Setting it in the <code>Routes</code> sets the session,  but after pages are loaded and thus working on the next page, instead on the current one.</p>
  
  <p>What's the best approach? Cause setting it in the <code>Routes</code> is surely not a good idea</p>