'User immediately logged out after submitting a form via POST route
Every time a form is submitted, the user is immediately logged out.
I have tried to start making my application again from scratch or even using Laravel built-in Authentication from make:auth but the problem still persists.
Currently I'm using Laravel 5.6.33
these are my code : web.php
<?php
Route::get('/', 'HomeController@index')->name('home');
Route::get('/posts','PostController@index');
Route::post('/posts','PostController@store');
Route::get('/posts/create','PostController@create');
Route::get('/posts/{id}/reply','ReplyController@create');
Route::post('/posts/{id}/reply','ReplyController@store');
Route::get('/register','RegisterController@create')->name('register.create');
Route::post('/register','RegisterController@store')->name('register');
Route::get('/login','LoginController@create')->name('login');
Route::post('/login','LoginController@store')->name('login.store');
Route::get('/password/reset','LoginController@reset')->name('password.request');
Route::post('/logout','LoginController@destroy')->name('logout');
And, in my PostController.php I put middleware
public function __construct(){
$this->middleware('auth')->except(['index','store']);
}
Where index is for listing my posts, and store is for save new post. there is also has function create to show the post form.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
