Hello everyone!
I have simple API login endpoint, this looks like this method in login controller:
public function login(Request $request)
{
$this->validateLogin($request);
if ($this->attemptLogin($request)) {
$user = $this->guard()->user();
return response()->json([
'data' => $user->toArray(),
]);
}
return $this->sendFailedLoginResponse($request);
}
With this simple route in /routes/api.php
Route::post('login', 'Auth\LoginController@login');
And this works fine, I can login to API via CURL command like this:
curl -X POST localhost/api/login -H "Accept: application/json" -H "Content-type: application/json" -d "{\"email\": \"test3@test3.local\", \"password\": \"test123\" }"
After this post request i get my user data in JSON format.
But I want use cookie to next login to my API, without enter login and password in every post request.
I think I can do it with CURL -b parameter to save session cookie and use it saved cookie with CURL -c parameter to next login to API
But when I try run curl -X POST localhost/api/login -H "Accept: application/json" -H "Content-type: application/json" -d "{\"email\": \"test3@test3.local\", \"password\": \"test123\" }" -b my_cookie
I can't get and save cookie and I don't have my_cookie file on my local filesystem.
How I must change my controller?
Where is my mistake?
Thanks in advance!