One Cookie - Multiple Pages

后端 未结 2 1256
攒了一身酷
攒了一身酷 2020-12-05 21:10

I am using the following cookie:

var $j = jQuery.noConflict();

$j(document).ready(function(){

   if (document.cookie.indexOf(\'visited=true\') == -1) 
            


        
相关标签:
2条回答
  • 2020-12-05 21:43
    document.cookie = valuename + "=" + value + "; " + expires + ";domain=;path=/";
    

    This "domain=;path=/"; will take dynamic domain as its cookie will work in subdomain. It will work if you want to test in localhost.

    0 讨论(0)
  • 2020-12-05 21:53

    Add ;path=/ to make your cookie into a site cookie. See this article on JavaScript Cookies for more details.

    0 讨论(0)
提交回复
热议问题