简体   繁体   English

页面刷新后Laravel 5.1注销

[英]Laravel 5.1 logout after page refresh

in very short, I made fresh install of laravel 5.1 via composer, set everything necessary and it runs without problem. 在很短的时间内,我通过composer重新安装了laravel 5.1,设置了所有必要的东西,并且运行顺利。 After I followed documentation to create login/register/logout, etc. All works fine, except there is one very important issue. 在我按照文档创建登录/注册/注销等之后,一切正常,除了一个非常重要的问题。

Everytime I navigate to other page, or refresh current page, I'm instantly logged out. 每次导航到其他页面或刷新当前页面时,我都会立即注销。 Session are set for 4 hours, storage folder has its rights and followed the documentation of 5.1 and also videos from Laracast. 会话设置为4个小时,存储文件夹拥有其权利,并遵循5.1的文档以及Laracast的视频。 Thing is same with socialite. 社交名流也一样。 Login easily, but after refresh Im logged out (session still there, also remember token). 登录很容易,但是刷新后我注销了(会话仍然存在,还记得令牌)。 Tried this on my mamp, on live server, same result. 在我的Mamp上,在实时服务器上进行了尝试,结果相同。

I have checked this thread as well, but I believe it works also without manual session set. 我也检查了线程,但我相信它也可以在不设置手动会话的情况下工作。 Or not? 或不?

Does anyone else experienced this? 还有其他人经历过吗? Thank you for any ideas. 谢谢您的任何想法。

Database session will sort out your issue.So 数据库会话将解决您的问题。

1)change session mode "file" to "database". 1)将会话模式“文件”更改为“数据库”。

2) create session table 2)创建会话表

php artisan session:table

composer dump-autoload

php artisan migrate

3)Clear config cache and re-set 3)清除配置缓存并重新设置

php artisan config:clear

php artisan config:cache

Assuming you are using the session driver to handle your authentication, you can change the time period for an idle session to expire in the /app/config/session.php file. 假设您正在使用会话驱动程序来处理身份验证,则可以在/app/config/session.php文件中更改空闲会话到期的时间。

'lifetime' => time() + 60 * 60 * 24 * 365, 
'expire_on_close' => true,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM