The following is a JavaScript cookie that has been written on a user's computer for 12 months.
After we set a cookie in our main domain, for example example.com , if a user visits a subobject, for example test.example.com , we need to continue identifying user activity through our βtestβ subdomain.
But with the current code, once they leave www.example.com and visit test.example.com , they are no longer marked as "HelloWorld".
Can someone help with my code so cookies can be read through subdomains?
<script type="text/javascript"> var cookieName = 'HelloWorld'; var cookieValue = 'HelloWorld'; var myDate = new Date(); myDate.setMonth(myDate.getMonth() + 12); document.cookie = cookieName +"=" + cookieValue + ";expires=" + myDate; </script>
javascript cookies
Evan Apr 15 '11 at 1:14
source share