We have 2 test environments, which are:
- http://test.example.com/ (This is our front end CMS testing site)
- http://test-example/ (This is our internal development site where form data is collected, etc)
Below is the cookie that is written on "test.example.com" domain. The user will reach the page where the cookie is written to their computer and then they will click a link that will take them to "test-example", which is our internal testing domain. I observed when they leave "test.example.com" and are taken to our internal testing domain "test-example" the cookie does not follow therefor I'm not able to read the cookie.
Would anyone be able to help with my code to allow the cookie to be read across our internal testing domain?
<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
+ ";domain=.example.com;path=/";
</script>