Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Suppress duplicate cookies #1710

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants

Suppress multiple instances of the same cookie being sent when multiple calls to Session::set_userdata are made. Currently, a call to _set_cookie is made on every call to set_userdata, and _set_cookie calls php's setcookie.

Contributor

narfbg commented Dec 1, 2012

How does this work? 128d719

Line 330 stores the initial cookie that would have been output. This is used in the initial comparison if nothing changes.

Lines 812-827 detect if the cookie to be output will be different from one that has already been output. This does not check if session data has been changed because that does not change the value of the cookie that will be sent to the browser.

The condition on 815 makes sure that a cookie will be sent at least once. 816 is a quick check to see if anything has been added between $cookie_data (which is the cookie that we want to send out) and $this->current_cookies (which is the cookie that was last sent out, and is now current to the browser). 817 is a more thorough check to see if there are value differences between the two arrays.

Since it looks like 128d719 fixes the duplicate cookie problem, I will close the pull request.

@samson-htw samson-htw closed this Dec 3, 2012

Contributor

narfbg commented Dec 3, 2012

That was kind of a call for testers. Can you confirm if it works for you?

The pull request I just closed works for me. I haven't tried 128d719 yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment