Are HTTP cookies port specific?

前端 未结 8 1896
傲寒
傲寒 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条回答
  •  遇见更好的自我
    2020-11-22 05:02

    I was experiencing a similar problem running (and trying to debug) two different Django applications on the same machine.

    I was running them with these commands:

    ./manage.py runserver 8000
    ./manage.py runserver 8001
    

    When I did login in the first one and then in the second one I always got logged out the first one and viceversa.

    I added this on my /etc/hosts

    127.0.0.1    app1
    127.0.0.1    app2
    

    Then I started the two apps with these commands:

    ./manage.py runserver app1:8000
    ./manage.py runserver app2:8001
    

    Problem solved :)

提交回复
热议问题