【问题标题】:Codeigniter set_flashdata returns page cannot be displayed on just this one serverCodeigniter set_flashdata 返回页面不能仅在这台服务器上显示
【发布时间】:2012-02-12 12:28:13
【问题描述】:

好吧,这很奇怪。我刚刚将 CodeIgniter 代码移到了我客户的虚拟主机 serverlogic.com。这段代码已经在 40 多台其他服务器上运行,但现在我突然陷入困境。我正在使用数据库会话。

这不起作用:

$this->session->set_flashdata('contact_message', validation_errors());
$this->session->set_flashdata('first_name', $this->input->post('first_name'));
$this->session->set_flashdata('last_name', $this->input->post('last_name'));
$this->session->set_flashdata('email', $this->input->post('email'));
$this->session->set_flashdata('zip', $this->input->post('zip'));
$this->session->set_flashdata('phone', $this->input->post('phone'));
$this->session->set_flashdata('comments', $this->input->post('comments'));

这行得通:

$this->session->set_flashdata('contact_message', validation_errors());
$this->session->set_flashdata('first_name', $this->input->post('first_name'));
$this->session->set_flashdata('last_name', $this->input->post('last_name'));
$this->session->set_flashdata('email', $this->input->post('email'));
/*$this->session->set_flashdata('zip', $this->input->post('zip'));
$this->session->set_flashdata('phone', $this->input->post('phone'));
$this->session->set_flashdata('comments', $this->input->post('comments'));*/

由于 set_flashdata() 方法使用 cookie 来跟踪数据,一旦 cookie 中存储的数据过多,是否会达到某些服务器限制?在调查我的服务器上的标头时,与此服务器相比,它设置了更多的 cookie。

我还从他们的服务器获取了一个 PHPSESSID cookie,但我不知道它来自哪里。我不是服务器管理员,因为他们使用的是 Nginx,所以我对这个完全一无所知。

【问题讨论】:

  • cookies 只能存储这么多信息,所以你可能会达到极限
  • 如果是 cookie 限制,难道不是所有设置都会发生这种情况吗?

标签: php codeigniter session cookies


【解决方案1】:

由于 set_flashdata() 方法使用 cookie 来跟踪数据,一旦 cookie 中存储的数据过多,是否会达到某些服务器限制?在调查我的服务器上的标头时,与此服务器相比,它设置了更多的 cookie。

您刚刚回答了自己的问题,

正如你所说,flashdata 使用 cookie 来存储数据,事实上只有这台服务器意味着有两种可能性。

  • 由于您的代码,此特定设置设置了更多数据(例如,您可能没有在其他设置中存储特定变量,而这恰好使此设置超出了边缘)。

  • 此服务器正在自行设置更多 cookie(nginx 可能),这也可能是 nginx 对您的 cookie 进行某种形式的内部重写的问题,因此域问题正在阻止 cookie 正常工作,但这不太可能。

你说你得到一个 page cannot be displayed 错误,我的建议是查看服务器日志以找出是否有任何错误。接下来使用 chrome 开发者工具或类似工具检查 cookie,看看数据是否看起来像是突然被切断了。

【讨论】:

  • 你证实了我的怀疑。如果设置不正确,显然 Nginx 和 cookie 会出现一些问题。 (large_client_header_buffers 和/或 proxy_buffer_size)。
【解决方案2】:

您是否尝试过注释掉每个 set_flashdata 以查看它是否是一个特定的语句?还是您从 cmets 向后工作?还是您只是碰巧从 zip 开始?

如果您使用数据库会话,则存储会话数据的表结构很重要。我唯一能想到的是,您的列没有针对数据类型和所存储的每个数据量的长度正确设置。

也许用您在服务器上定义的其他表仔细检查表结构。

【讨论】:

    猜你喜欢
    • 2020-05-27
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多