Answer the question
In order to leave comments, you need to log in
Why doesn't Laravel user remembering work?
Hello. I am doing a small educational project on Laravel. It was required to make non-standard authentication (based on a token, not a login \ password).
I sketched a little code for testing:
Route::get('/login',function(){
Auth::login(User::findOrFail(1),true);
echo('Login OK');
});
Route::get('/check_u',function(){
dd(Auth::user());
});
Route::get('/logout',function (){
Auth::logout();
});
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $user_id;
protected $f_name;
protected $l_name;
protected $auth_token;
}
echo('Login OK');
Answer the question
In order to leave comments, you need to log in
if you remove the line echo('Login OK'); then everything is fine
headers already sent
. Note:
To use cookie-based sessions, the session_start() function must be called before rendering anything to the browser .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question