我已经搜索了所有主题,但没有任何帮助。在我的 Laravel 安装中,有时您必须在登录和注销后重新加载页面才能使其可见。极少情况下您根本没有登录或退出。我使用 Laravel 5.6.39。登录控制器namespace App\Http\Controllers\Auth;use App\Http\Controllers\Controller;use Auth;use Illuminate\Foundation\Auth\AuthenticatesUsers;use Illuminate\Http\Request;use Illuminate\Support\Facades\Redirect;use Session;class LoginController extends Controller{ use AuthenticatesUsers; protected $redirectTo = '/'; public function __construct() { $this->middleware('guest')->except('logout'); } protected function authenticated(Request $request, $user) { } public function logout() { Auth::logout(); Session::flush(); return Redirect::to('/'); }}配置/会话.phpreturn [ 'driver' => env('SESSION_DRIVER', 'database'), 'lifetime' => env('SESSION_LIFETIME', 120), 'expire_on_close' => false, 'encrypt' => true, 'files' => storage_path('framework/sessions'), 'connection' => 'mysql', 'table' => 'sessions', 'store' => null, 'lottery' => [2, 100], 'cookie' => env( 'SESSION_COOKIE', str_slug(env('APP_NAME', 'laravel'), '').'session' ), 'path' => '/', 'domain' => env('SESSION_DOMAIN', null), 'secure' => env('SESSION_SECURE_COOKIE', false), 'http_only' => true, 'same_site' => null,];RedirectIfAuthenticated.php中间件<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Support\Facades\Auth;class RedirectIfAuthenticated{ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect('/'); } return $next($request); }}我还尝试更改 cookie 名称,定义 cookie 域,将会话从文件更改为数据库。没有任何帮助。
- 1 回答
- 0 关注
- 154 浏览
添加回答
举报
0/150
提交
取消