Cannot set cookies in Javascript

后端 未结 9 2187
青春惊慌失措
青春惊慌失措 2020-12-01 10:28

I have a very simple line of code that set and read a cookie. I kept getting empty value for my cookie and have no understanding why. I have cookie enabled and know that coo

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 11:05

    I get the same weird behavior when opening a page in Chrome from localhost

    When I map the same page in my hosts file and open the same page through the mapped name, normal cookie functionality resumes.

    1. Open you hosts file as admin. (usually c:\windows\system32\drivers\etc\hosts)
    2. Add 127.0.0.1 localhostdevelopment.com or similar to the end of your hosts file
    3. Save your hosts file (will be rejected if you did not open the file as admin)
    4. Go to http://localhostdevelopment.com/ (or whatever you called it) in Chrome.
    5. Please enjoy having your cookies behave normally.

提交回复
热议问题