Auth::check()
始终返回false。这很奇怪,因为登录函数会将我重定向到$ redirectTo url,因此尝试是成功的,但之后我无法检索用户。我正在使用Laravel 5.2.14和Xampp。除了它应该开箱即用之外,我不知道还要写什么。
这是php artisan route:list的输出。
+--------+----------+---------------+------+-------------------------------------------------------+----------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+---------------+------+-------------------------------------------------------+----------------+
| | GET|HEAD | / | | Closure | |
| | GET|HEAD | add | | Closure | web,auth.basic |
| | POST | addclub | | App\Http\Controllers\Clubs@addclub | web |
| | POST | auth/login | | App\Http\Controllers\Auth\AuthController@postLogin | web,guest |
| | GET|HEAD | auth/login | | App\Http\Controllers\Auth\AuthController@getLogin | web,guest |
| | GET|HEAD | auth/logout | | App\Http\Controllers\Auth\AuthController@getLogout | web,guest |
| | POST | auth/register | | App\Http\Controllers\Auth\AuthController@postRegister | web,guest |
| | GET|HEAD | auth/register | | App\Http\Controllers\Auth\AuthController@getRegister | web,guest |
| | GET|HEAD | delete/{id} | | App\Http\Controllers\Clubs@delete | |
| | GET|HEAD | details/{id} | | App\Http\Controllers\Clubs@details | |
| | GET|HEAD | listofclubs | | App\Http\Controllers\Clubs@listofclubs | |
+--------+----------+---------------+------+-------------------------------------------------------+----------------+
我的config/sessions.php文件:
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
];
Auth::check
"不起作用"?但是无论如何,你在其中4个路由上缺少了 'web' 中间件。 - lagboxClubs
控制器和routes.php
吗? - huuuk