【问题标题】:PHP sessions not saving on page refresh or after going to another pagePHP会话不保存页面刷新或转到另一个页面后
【发布时间】:2019-04-28 15:21:57
【问题描述】:

我的会话没有保存页面刷新或转到另一个页面。这一切都是在使用 composer update 更新我的所有作曲家文件并将我的 EC2 服务器从 t2.nano 升级到 t2.micro 之后开始发生的。不知道是什么原因造成的?

我已尝试使用此代码来查看我的会话是否正在保存并且它正在保存:

if (!is_writable(session_save_path())) {
    echo 'Session path "'.session_save_path().'" is not writable for PHP!'; 
}

这是我测试我的 SESSION 代码的方式:

<?php
session_start();

$_SESSION['test'] = 'ok'; // 1st time loading the page works. I remove this line on the second refresh and the var_dump below does not show the session.

var_dump($_SESSION);
die();

?>

【问题讨论】:

  • 你检查浏览器是否有苦力?
  • @SimonMüller 我已经尝试过隐身,我已经尝试过我的手机浏览器

标签: php amazon-web-services session amazon-ec2 composer-php


【解决方案1】:

我太傻了。我正在使用 IP 地址在我的开发站点上工作,但我有 session.cookie_secure = 1 这使它无法正常工作。我不得不禁用它,所以我只是将其注释掉:

;session.cookie_secure = 1

【讨论】:

    猜你喜欢
    • 2013-01-28
    • 2013-07-19
    • 2017-02-15
    • 2013-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多