dongzhang0418 2011-09-13 13:34
浏览 309
已采纳

PHP中的setcookie可以产生多个“Set-Cookie”标题吗?

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...

  • 写回答

1条回答 默认 最新

  • doujia3441 2011-09-13 13:39
    关注

    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...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?