Support the ongoing development of Laravel.io →
Authentication Session Installation

Hello, I've got this problem with the Auth::user() object not working properly when using subdomains. I'm running my local development website using XAMPP on localhost and I've got the subdomains admin.localhost and boards.localhost.

/*
    |--------------------------------------------------------------------------
    | 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' => false,

I get the error trying to get property of non-object. I've made multiple google searches and looked through various pages but nothing has solved my problem. I've tried these variations:

    'domain' => 'localhost'
...
    'domain' => '.localhost'
...
    'domain' => '*.localhost'

but no better results from that. Could someone guide me to a proper solution or is a custom solution required?

Last updated 3 years ago.
0

I think it should be

'domain' => '.localhost'

However if the cookie was set before you made this change you probably need to delete them or clear browser cache

0

Using

    'domain' => '.localhost'

Laravel doesn't create any cookie, and I still can't authenticate.

0

Using

'domain' => '.localhost'

Mozilla Firefox does authenticate but Chrome and IE11 doesn't. However Firefox can't connect to subdomains like admin.localhost for some reason that I can't figure out

Last updated 9 years ago.
0

Any update on this issue?

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.