gpt4 book ai didi

Laravel 身份验证,我无法检索登录用户

转载 作者:行者123 更新时间:2023-12-01 10:34:52 25 4
gpt4 key购买 nike

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 | |
+--------+----------+---------------+------+-------------------------------------------------------+----------------+

我的配置/ session .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,

];

最佳答案

确保你所有的路由都包含在同一个“路由组”和“前缀”中

route::get('/','myController@myAuthMethod'); /* this will not show your user because its an independent route  */

route::group(['prefix'=>member,'Middleware'=>yourMiddleware],function(){


route::get('a','AuthController@getLogin');
route::get('b','AuthController@getLogout');
route::post('c','AuthController@postRegister');
route::get('d','AuthController@getRegister');
route::get('e','Clubs@delete');
route::get('f','Clubs@details');
route::get('g','Clubs@listofclubs ');
/* a,b,c,d,e,f and g views will show your authenticated user */
});

关于Laravel 身份验证,我无法检索登录用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37470726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com