EllisLab/CodeIgniter — pull request #1780 by aaronpk (2012-09-10 00:55:16+00:00)
Title: Prevent sending multiple Set-Cookie headers

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.

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)

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

Signed-off-by: Aaron Parecki