0

In session table, user id is null when user visit guest page.

Route::get('/', [HomeController::class, 'index',])->name('home');

Route::group(['middleware' => ['auth:user']], function () {

    Route::get('/dashboard', [HomeController::class, 'dashboard'])->name('dashboard');

});

When user visit dashboard, session table has user id and same user goes to home page user id is now set as null in session table.

parth
  • 1,803
  • 2
  • 19
  • 27

1 Answers1

0

Maybe this can help

Route::middleware('auth')->group(function () {
    Route::get('/dashboard', [HomeController::class, 'dashboard'])->name('dashboard');
});
  • Problem is home page not dashboard, home page is for both user and guest. – parth Mar 17 '21 at 09:25
  • Seen from your code, saying that the home page doesn't require authentication. so home page can be accessed for both user and guest. maybe you need `@auth user activity @endauth` or `@guest guest activity @endguest` ref: https://laravel.com/docs/8.x/blade#authentication-directives – Guna Wirawan Mar 17 '21 at 09:54
  • This is not about the blade, its about session table. – parth Mar 17 '21 at 10:19