Arnaud Ad Arnaud Ad - 1 year ago 87
jQuery Question

Setting cookies on subdomain with jquery

The domain of my website which is, let's say, has a subdomain

When the user clicks on a link on i need to set a cookie on

I tried the following block of code but the cookie is only set on the current domain and not

$.cookie("redirectLanguage", "en", { expires: 365,domain: ''});

thanks for your help!

Answer Source
baseDomain = '',
expireAfter = new Date();

document.cookie="Name="FName"; domain=" + baseDomain + "; expires=" + expireAfter + "; path=/";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download