I need to pass variable se session to get variables in other views or controllers at the end I get a NULL
This is what I am doing:
public function login(Request $request){
$client = new Client();
$this->validate($request, [
'email' => 'email|required',
'password' => 'min:3|max:100',
]);
$response = $client->post("http://localhost:8000/v1/login", [
'headers' => ['foo' => 'bar'],
'json' => [
'email' => $request['email'],
'password' => $request['password'],
]
]);
$user = Session::put('response', $response);
dd($user);
}
On the screen the result is Null
In my other controller I do not get anything in the view:
public function index(){
$user = Session::get('response');
return view('pages.home', compact('user'));
}
What is the correct way to obtain these variables in other controllers and views?