Hi, I am the author of this other post: https://laracasts.com/discuss/channels/requests/i-dont-cant-to-get-the-cookie
I am beginning to write posts here with the intention of getting help to my project...
Currently, I am implementing the authentication, and in /api/login I am writting the login logic that is as follows...
public function login(Request $request) {
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
return redirect()->intended('/articles');
// return var_dump(Auth::user());
} else {
return response('bad petition');
}
}
If I return Auth::user I get the user found on the login, but if I aim to recover the user later in other petition, I get null, for example in /articles:
public function index(Request $request)
{
//
$posts = Article::paginate(10);
//return View('pages.articles.index', ['posts' => $posts, 'token' => Cookie::get('token')]);
return response(var_dump(Auth::user()));
}
Please, help, I was through all day trying to solve the problem!