The Surrican
The Surrican

Reputation: 29866

Can setcookie in PHP result in multiple "Set-Cookie" headers?

I am debugging an issue with a Magento system.

The problem is a duplicated Set-Cookie header, like this:

Set-Cookie: flimmit_session=search-0c30086b812519b006aa27ef4f37f15b-24; path=/; domain=.flimmit.com; httponly
Set-Cookie: flimmit_session=search-0c30086b812519b006aa27ef4f37f15b-24; path=/; domain=.flimmit.com; httponly

The cookie is set using php's setcookie command. My question is whether the incorrect use of this function can result in a duplicate Set-Cookie header, or whether I have to look somewhere else for the error...

Upvotes: 8

Views: 6920

Answers (1)

DaveRandom
DaveRandom

Reputation: 88657

Yes, calling setcookie() twice with the same data will result in 2 identical Set-Cookie: headers. I have just tried it, and it does.

It shouldn't cause a problem though, the cookie will always have the value defined by the last setcookie() call...

Upvotes: 9

Related Questions