重复的“set-cookie:ci-session”标题中的字段 [英] Duplicated "set-cookie: ci-session" fields in header by codeigniter

查看:534
本文介绍了重复的“set-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:s?

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.

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

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