0
votes

I have 2 sites on two domains: site.info(legacy) and sub.site.info(on other server, with other code base on Laravel5.5). I need: when you authorized on site.info and visit sub.site.info laravel read your cookie and auto authorize you on site.

What I made:

Created Middleware "StartSession" who extend Illuminate\Session\Middleware\StartSession with method startSession:

public function startSession(Request $request)
    {
        event(new SiteAuth($session=parent::startSession($request)));
        return $session;
    }

In Http\Kernel.php replaced original middleware.

Created:

  • Provider (SiteAuthServiceProvider) and registered my StartSession
  • Event (SiteAuth)
  • Listener (SiteAuthListener),

I will write my auth code in SiteAuthListener@handle.

Is it right way?

Thanks.

1

1 Answers

0
votes

I believe you can change the session config file (yourproject/config/session.php) and add the domain, which in your case is 'yoursite.ttf'.

'domain' => 'yoursite.ttf'

or more elegant way is

'domain' => env('DOMAIN')// which will be inside .env file (DOMAIN=yoursite.ttf)