0

I changed my laravel session driver to database. I changed the session.php file and the ENV file to reflect database. I didn't define a connection and left it default in the session.php file.

I have the session table created through the php artisan command, did the migration.

I come across the "TokenMismatchException in VerifyCsrfToken.php line 67:" error now everytime I submit a form. If I revert back to "file" it goes back to normal.

I have cleared artisan cache clearing, browser history clearing too.

Using laravel 5.2.

Any help is greatly appreciated.

Ela Buwa
  • 1,652
  • 3
  • 22
  • 43
  • 1
    Are any tokens added to your database table? – Frnak Aug 09 '16 at 13:27
  • @FrankProvost the payload column has values. but the user_id column is null – Ela Buwa Aug 09 '16 at 17:42
  • Did you create the session dable using php artisan session:table ? Ensure you called composer dump-autoload after that – Frnak Aug 10 '16 at 05:15
  • Yes. any idea why this is happening? It becomes ok when I switch back to file driver. My main reason for switching to databases is that the user is auto logged out after a few minutes. My session expire is set to default value of 120 mins. – Ela Buwa Aug 10 '16 at 09:53
  • Sadly I do not have an idea why this is happening. However, I think you can also handle session expiration in files / cookies. – Frnak Aug 10 '16 at 11:43
  • @FrankProvost thank you for the help. for some reason it didn't work on my computer. I got my other development partner to do it in his computer and simply pulled in a GIT request and it worked for some reason. Must be one of those things eh. – Ela Buwa Aug 12 '16 at 06:42

1 Answers1

0

One reason this can happen is if you created sessions table manually and made the mistake of making id column of type bigint(20) or any other mismatching column. Check my detailed answer here https://stackoverflow.com/a/45340647/7260022

Waku-2
  • 1,136
  • 2
  • 13
  • 26