I have three different laravel websites, I want to make user sign in at one website then he will be automatically logged in to the other two websites. eg. if you logged in at your stackoverflow then open stackexchange you will be logged in with StackOverflow account. I have tried many packages but they end with infinite exceptions or they simply not working. Most of the packages based on SAML, I have no idea why it did not work with me? I do not know what I miss? Is there any config for this to work? I am using laravel 5.6. All the apps are on the same server.
I have tried many solutions based on SAML, OpenID and share session, but all of them did not work with me. I do not know if I miss something. this is the last example I tried and it did not work
this is my code
SITE A
$site_b = 'http://s_sesstion_2.test/';
Route::get('/', function (Request $request) use ($site_b) {
$session_id = Session::getId();
try {
$http = new Client();
$response = $http->post($site_b . 'api/sessions/server', [
'form_params' => [
'session_id' => $session_id,
],
'headers' => [
'Accept' => 'application/json',
]
]);
} catch (Exception $e) {
dd($e->getMessage());
}
return view('welcome');
});
SITE B (route/api.php)
Route::post('/sessions/server', function (Request $request) {
Storage::disk('local')->put('file.txt', $request->get('session_id'));
});
SITE B (route/web.php)
Route::get('/', function () {
$session_id = Storage::disk('local')->get('file.txt');
Session::setId($session_id);
Session::start();
//return Session::getId();// will return the same session id
return \auth()->user();//this should return the auth user but it did not!!
});
All I want is to sign in at site A then open site B I will be signed in. I will accept any solution achieve that purpose