Level 41
If you dd the application, you are killing it before it can properly set the user's session. You need to let the application terminate itself in order for sessions to work properly.
1 like
Summer Sale! All accounts are 50% off this week.
Hello, I have a strange behaviour regarding Session, When playing with Socialite, I added an email key to the session, I can see it right after adding it when I hit /social/auth/facebook/callback but when i hit /lab/session which just a dd(session()->all()) I have no email key
any idea ?
public function handleProviderCallback($provider)
{
try {
$user = Socialite::driver($provider)->user();
}
catch (\GuzzleHttp\Exception\ClientException $e) {
return redirect('social/auth');
}
// storing data to our use table and logging them in
$data = [
'first_name' => $user->user['first_name'],
'last_name' => $user->user['last_name'],
'name' => $user->getName(),
'email' => $user->getEmail(),
'avatar'=> $user->getAvatar(),
//'originalAvatar' => $user->getAvatar_original(),
];
echo 'Socialite User :<br/>';
var_dump($user);
echo 'Data :<br/>';
var_dump($data);
$dataSerialized = serialize($data);
echo 'Data serialized :<br/>';
var_dump($dataSerialized);
$dataUnSerialized = unserialize($dataSerialized);
echo 'Data unserialized :<br/>';
var_dump($dataUnSerialized);
//Put the facebook user ID into Session
session()->put('email',$user->getEmail());
//\Session::put('email',$user->getEmail());
echo 'Session :<br/>';
var_dump(session()->all());
//Auth::login(User::firstOrCreate($data));
//after login redirecting to home page
dd('done');
return redirect('register');
}
If you dd the application, you are killing it before it can properly set the user's session. You need to let the application terminate itself in order for sessions to work properly.
Please or to participate in this conversation.