Answer the question
In order to leave comments, you need to log in
How to create a cookie on login?
Hello!
I'm just starting to understand this framework, so some questions may seem too simple for you, but for me they are so far (!) Not quite simple. So don't judge. I really hope you can help me with my questions.
There is such a method in the controller responsible for authorization in the admin panel:
public function enter(Request $request)
{
$login = $request->input('login');
$password = md5($request->input('password'));
$language = $request->input('language');
$user = User::where('login', $login)->andWhere('password', $password)->first();
if ($user) {
/* Создать cookie. */
return redirect('backend.dashboard');
} else {
$error = 'Не правильно введены логин или пароль.';
$errors = [
'errors' => $error
];
return redirect('backend')->with($errors);
}
}
Answer the question
In order to leave comments, you need to log in
Why are you reinventing the wheel?
Everything is in the documentation: https://laravel.ru/docs/v5/authentication
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question