title: Laravel database session not working when setting a session domain
body: <p>I encounter issues with the database driver in order to store sessions cookies:</p>
  <p>The database connection is currently working but cookies are not set in the browser however session data are in my database.</p>
  <p><strong>I have run:</strong></p>
  <pre class="lang-sh prettyprint-override"><code>php artisan session:table
  </code></pre>
  <p><strong>Set database session in my <code>.env</code> file:</strong></p>
  <pre><code>SESSION_DRIVER=database
  </code></pre>
  <p>Bellow the <code>config/session.php</code> file:</p>
  <pre class="lang-php prettyprint-override"><code>[
      'driver' =&gt; env('SESSION_DRIVER', 'file'),
      'connection' =&gt; 'mysql',
      'table' =&gt; 'sessions',
  ]
  </code></pre>
  <p><strong>EDIT 1:</strong></p>
  <p>The route in <code>web.php</code>:</p>
  <pre class="lang-php prettyprint-override"><code>Route::group(['domain' =&gt; GetDomainInfo::GetDomainName(), 'middleware' =&gt; 'web'], function () {
      Route::get('/', &quot;HomeController@index&quot;);
  });
  </code></pre>
  <h1>Solved issue by :</h1>
  <p>I have created for example a localhost domain: <strong>webcv</strong> by adding to my <code>hosts</code> file:</p>
  <pre><code>127.0.0.1 webcv.local
  127.0.0.1 admin.webcv.local
  </code></pre>
  <p>Set the session domain to : <strong>.webcv.local</strong> in <strong>config/session.php</strong> like so:</p>
  <pre class="lang-php prettyprint-override"><code>'domain' =&gt; env('SESSION_DOMAIN', &quot;.webcv.local&quot;),
  </code></pre>
  <p>Or just by adding in the <code>.env</code> file:</p>
  <pre><code>SESSION_DOMAIN=.webcv.local
  </code></pre>
  <p>Now I can access to both <code>webcv.local</code> and <code>admin.webcv.local</code> with the same cookie.</p>