问题
I converted my MySQL database to SQLite one, but now the login system is not working anymore. I'm using DATABASE=sqlite
and SESSION_DRIVER=file
. What's wrong?
When I type my email and password and press Login, the system redirects me at Login page again without any error messages.
I tried to change the redirect route after login many times, and only that are unauthenticated routes are working; This is because Auth::user or auth()->user()
are Undefined objects. The login is going well, because if I make a typo in password the system tells me that credentials are wrong.
Obviously, I tried to do queries when SQLite database is set and are working well (App\User::first()->name in login.blade.php
, for example).
I tried to revert DB_CONNECTION=mysql
and all works as expected (as before too): when I login with my email and password the system redirects me to the dashboard.
I'm using Laravel 5.7 in Windows 10 with SQLite 3.26.
EDIT Part of my .env file
APP_NAME=*****
APP_ENV=local
APP_KEY=******
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=sqlite
DB_DATABASE=database.sqlite
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
...
SNAPPY_PDF_BIN='C://"Program Files"/wkhtmltopdf/bin/wkhtmltopdf'
SNAPPY_IMG_BIN='C://"Program Files"/wkhtmltopdf/bin/wkhtmltoimage'
SES_KEY=****
SES_SECRET=****
回答1:
I found the solution. Laravel did not have any problem, the problem was the sqlite database (the file). It was not well converted from mysql to sqlite. In the end the only thing that worked is the "famous" bash script "mysql2sqlite.sh" that you can find here. It only works for me with database empty. With data, I get an error when doing the conversion.
I hope I can help someone, greetings!
来源:https://stackoverflow.com/questions/53958991/laravel-doesnt-keep-session-when-use-sqlite-database