Retrieving cookie on subdomain that was created on main domain

42 Views Asked by At

I have been researching not only this site, but also around the web and cannot find the solution. I have full access to both domains.

The code in my main domain (test.com.es) is:

<script type="text/javascript"> 
jQuery(document).ready(function($){ 
$('.quote_button').click(function(e) { 

//create product number cookie 
var itemname = $('.colors_productname span').html(); 
document.cookie= 'product_id=' + itemname + '; path=/';

(I have entered the following after path=/';domain = "test.com.es";) - This is still not working.

`e.preventDefault(); 
document.location.href='http://contact.test.com'; 
}); 
}); 
</script> `

In my subdomain I have the code:

    Product SKU* <input class="right" id="skew" size="30" name="skew" value="" type="text"/><br/>
<script type="text/javascript">
$(document).ready(function() {
   function getCookie()
   {
   var name = 'product_id=';
   var ca = document.cookie.split(';');
   for(var i=0; i<ca.length; i++) 
     {
        var c = ca[i].trim();
        if (c.indexOf(name)==0) 
        {
           var productname = c.substring(name.length,c.length);
           return productname;
        }
     }
   }
var product = getCookie();
$('#skew').val(product);
});
</script>

Can someone please assist in why this is not pulling through?

Thanks

DB

0

There are 0 best solutions below