When I am submitting my forms in laravel, the user session expires and it logs out the current user. I thought it was a csrf token problem, so I disabled its verification but the problem persists.
My view
<form action="{{url('/save-user-details')}}" method="POST" enctype="multipart/form-data"
>
@csrf
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Primeiro Name</label>
<input type="text" class="form-control"
name="firstName" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Apelido</label>
<input type="text" class="form-control" name="lastName" required>
</div>
</div>
</div>
<button type="submit" class="button pull-right" value="">Actualizar Perfil</button>
</form>
My Route list
Route::post('/save-user-details', 'DashboardController@saveUser');
Route::get('/editar-usuario', 'DashboardController@editProfile');
My Controller
public function __construct()
{
$this->middleware('auth');
}
public function saveUser(Request $request){
$user_id = auth()->user()->id;
$user = User::find($user_id);
$detalhes = new Detalhesuser;
$detalhes->user_id = $user_id;
$detalhes->firstName = $request->input('firstName');
$detalhes->lastName = $request->input('lastName');
$detalhes->profissao = $request->input('profissao');
$detalhes->instituicao = $request->input('instituicao');
$detalhes->biografia = $request->input('biografia');
$detalhes->save();
$user->detalhesUser_id = $detalhes->id;
$user->save();
return redirect('/dashboard')->with('success', 'Detalhes salvos');
}
My sessions are being stored in a file. I tried to change it to database, the problem still persisted.
Any idea where I may be doing this wrong?