0

I try to access the current user in my custom middleware from the web group.

To use the session on multiply domains I set the domain value in the session config 'domain' => env('SESSION_DOMAIN', '.localhost'),. Then I login to my application.

When I call http://localhost the content of $request:user() is not null. But when I call http://test.localhost the object is null.

What is wrong?

Markus
  • 1,909
  • 4
  • 26
  • 54
  • if you logout and then login from http://test.localhost/login, do you then see a user on the test domain but not on the primary domain? seems like it's treating the domain as a separate site, and sessions aren't going to work across the domains – eResourcesInc Oct 29 '18 at 20:06
  • I can't login on the test domain usign the same auth routes like on the primary domain but I get validation errors. It seems like the session isn't working. – Markus Oct 29 '18 at 20:09
  • That's odd, using the .localhost domain should make the session work across subdomains. This isn't really an answer to your specific issue, but have you tried using Laravel Valet? That makes subdomains a lot easier to work with. Then you can just do something like this: https://medium.com/@rcubitto/configure-subdomains-in-laravel-valet-48ac6759a438 – eResourcesInc Oct 29 '18 at 20:14

0 Answers0