Probelm writing cookie with a domain name
<p>Below is the code I am writing to set the cookie with domain name= “.example.com” but this isn’t working.  Any idea what’s wrong with the code? However if I remove the domain name, it works fine.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;

function setCookie(c_name,value,exdays)
{
       alert("Cookie = " + document.cookie);

       var c_value=escape(value);`enter code here`

       var myDate = new Date();

       myDate.setMonth(myDate.getMonth() + 12);
       document.cookie = c_name +"=" + value + ";expires=" + myDate + ";domain=.example.com;path=/";

}

&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="setCookie('name','value')"&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Any help would be great. </p>

<p>Thanks. </p>
