1

My Laravel 5.6 project was working well.

But suddenly when I try to login sometimes it says

The page has expired due to inactivity.

and sometimes it login properly with out any error. For example

  • I go to page 127.0.0.1:8000/login...submit login form and get that error.

  • I refresh the 127.0.0.1:8000/login page...submit...again error.

  • I refresh the 127.0.0.1:8000/login page...submit and it works properly :|

Anybody know whats wrong with my project?!

this project works on my host without any problem and I have {{ csrf_field }} in my form.

I've tried to clear cache, view, route, config and deleting browser cache/cookie and change SESSION_DRIVER=array but still got error.

UPDATE : another thing that i should say is when it work properly and i login to the panel...when i submit any forms i got out of the panel and i should login again.

jesugmz
  • 2,320
  • 2
  • 18
  • 33

2 Answers2

0

for localhost development open kernel.php inside Http folder and just comment this line :

\App\Http\Middleware\VerifyCsrfToken::class,

the csrf protection of laravel doesn't work properly on localhost. I already tried everything. just comment that, it's very annoying problem.

Amin Adel
  • 970
  • 3
  • 17
  • 33
0

finaly...after 3 bad days focus on this issue...i find the answer and i hope it help someone else :

check your browser setting -> cookies and see how many cookies create when a user login.

by default laravel create 2 cookies when user login with names :

  1. "XSRF-TOKEN"
  2. "laravel_session"

these are ok but other cookies which you create manually or other installed packages creates cause this problem.

i was using eloquent-viewable package and it creates a cookie everytime i logged in.

i remove this package and then everything works properly :)