linux - Laravel:部署到服务器时会话不会保持活动状态
问题描述
每次我对用户进行身份验证时,只要我不离开页面或关闭选项卡,会话就会保持活动状态,但是,当我再次访问页面时,会话将关闭,我必须再次进行身份验证,仅此而已当我部署服务器时发生,因为它在本地正常工作,我已经查看了所有相关文件,这是我的 session.php 文件
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Session Driver
|--------------------------------------------------------------------------
|
| This option controls the default session "driver" that will be used on
| requests. By default, we will use the lightweight native driver but
| you may specify any of the other wonderful drivers provided here.
|
| Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array"
|
*/
'driver' => env('SESSION_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/
'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false,
这是我的 .env 文件
BROADCAST_DRIVER=log
CACHE_DRIVER=array
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
服务器上我项目中的所有文件夹都有 777 权限,会发生什么?
解决方案
使用数据库会话驱动程序将解决您的问题并提高代码质量。查看此文档部分,了解如何配置它。
推荐阅读
- android - 具有透明背景的弹出对话框
- python-3.x - 即使 if 语句在 Python 中为真,程序也会打印 else 条件
- kubernetes - Helm 忽略指定版本并安装最新版本
- python - 如何使用 Python 使用 GraphQL 令牌?
- c - 我如何在 Netbeans 中使用 Input 运行 C 程序
- powershell - 在多个 VLAN 适配器上创建静态 IP 地址的脚本
- c# - 无法让 Roslyn 使用 .NET 5 项目
- performance - 在某些情况下,哈雷的方法迭代会比牛顿的更好吗?
- python - Python 脚本将文件保存在用户输入目录之上的一个目录
- answer-set-programming - 将所有答案集收集到一个答案集 (ASP)