复制的“设置cookie:ci-session”由标识符标题中的字段 [英] Duplicated "set-cookie: ci-session" fields in header by codeigniter

查看:285
本文介绍了复制的“设置cookie:ci-session”由标识符标题中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的控制器中每次使用$ this-> session-> set_userdata()或$ this-> session-> set_flashdata()时,将另一个相同的Set-Cookie:ci_session = ...添加到

For each time $this->session->set_userdata() or $this->session->set_flashdata() is used in my controller, another identical "Set-Cookie: ci_session=..." is added to the http header the server sends.

根据rfc6265,在http标头中具有相同cookie名称的多个Set-Cookie字段不正确。

Multiple Set-Cookie fields, with the same cookie name, in the http header is not okay according to rfc6265.

所以有没有办法使用codeigniter会话创建多个相同的set-cookie:?

So is there a way to use codeigniter sessions without it creating multiple identical "set-cookie:"s?

使用curl来验证http标头)

(I've used curl to verify the http header)

推荐答案

检查 https://github.com/EllisLab/CodeIgniter/pull/1780


默认情况下,当使用cookie会话处理程序(加密或未加密)时,每当向会话写入新值时,CI会发送整个Set-Cookie头文件。这导致多个头文件被发送到客户端。

By default when using the cookie session handler (encrypted or unencrypted), CI sends the entire "Set-Cookie" header each time a new value is written to the session. This results in multiple headers being sent to the client.

这是一个问题,因为如果太多的值被写入会话,那么HTTP头可能会变得非常大,一些Web服务器将拒绝该响应。 (请参阅 http://wiki.nginx.org/HttpProxyModule#proxy_buffer_size

This is a problem because if too many values are written to the session, the HTTP headers can grow quite large, and some web servers will reject the response. (see http://wiki.nginx.org/HttpProxyModule#proxy_buffer_size)

解决方案是在输出页面内容之前,只有在发送所有其他标题后才运行'sess_save()'。

The solution is to only run 'sess_save()' one time right after all other headers are sent before outputting the page contents.

这篇关于复制的“设置cookie:ci-session”由标识符标题中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆