I have a website which allows both access to www.mywebsite.com and mywebsite.com.
However this gives me a cookie problem, because a user which logs on to www.mywebsite.com does not have a session on mywebsite.com, because the cookie domain is set to the domain in use.
Is there a way in Laravel to force cookies to be set on the root mywebsite.com? This would remove the problem. I tried changing the session domain in Session.php without luck.
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => '.mywebsite.com',
Also, found it myself in CookieServiceProvider.php. It is indeed set from Session.php:
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('cookie', function ($app) {
$config = $app['config']['session'];
return (new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']);
});
}