Are HTTP cookies port specific?

前端 未结 8 2034
傲寒
傲寒 2020-11-22 04:14

I have two HTTP services running on one machine. I just want to know if they share their cookies or whether the browser distinguishes between the two server sockets.

8条回答
  •  萌比男神i
    2020-11-22 05:06

    This is a really old question but I thought I would add a workaround I used.

    I have two services running on my laptop (one on port 3000 and the other on 4000). When I would jump between (http://localhost:3000 and http://localhost:4000), Chrome would pass in the same cookie, each service would not understand the cookie and generate a new one.

    I found that if I accessed http://localhost:3000 and http://127.0.0.1:4000, the problem went away since Chrome kept a cookie for localhost and one for 127.0.0.1.

    Again, noone may care at this point but it was easy and helpful to my situation.

提交回复
热议问题