Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auth::user() doesn't travel across subdomains? - Laravel 5.2

I have a subdomain in my site, for example:

http://example.ca
http://blog.example.ca

The blog one is only accessible to people who have the url, that is, its not public or common knowledge. I have a bunch of routes related to this domain that requires you to be logged in.

I have stated in a nav.blade.php that if the user is logged in, there should be a drop down and if not then there should not be a drop down.

this all works for http://blog.example.ca but when I go to http://example.ca I am not authenticated any more.

Is there any way in larval to make me authenticated across all subdomains? Not just the ones who have controller actions that require me to be authenticated?

like image 732
TheWebs Avatar asked Dec 28 '15 06:12

TheWebs


1 Answers

In config/session.php you should change:

'domain' => null,

into

'domain' => '.example.ca',

You should also clear all the cookies

like image 115
Marcin Nabiałek Avatar answered Nov 17 '22 05:11

Marcin Nabiałek