How do I set path while saving a cookie value in JavaScript?

前端 未结 5 1041

I am saving some cookie values on an ASP page. I want to set the root path for cookie so that the cookie will be available on all pages.

Currently the cookie path is

5条回答
  •  忘掉有多难
    2020-12-02 16:05

    simply: document.cookie="name=value;path=/";

    There is a negative point to it

    Now, the cookie will be available to all directories on the domain it is set from. If the website is just one of many at that domain, it’s best not to do this because everyone else will also have access to your cookie information.

提交回复
热议问题