Reputation:
The domain of my website which is, let's say, mydomain.com has a subdomain en.mydomain.com
When the user clicks on a link on mydomain.com i need to set a cookie on en.mydomain.com
I tried the following block of code but the cookie is only set on the current domain mydomain.com and not en.mydomain.com
$.cookie("redirectLanguage", "en", { expires: 365,domain: '.mydomain.com'});
thanks for your help!
Upvotes: 2
Views: 2039
Reputation: 1355
//variables
baseDomain = '.domain.com',
expireAfter = new Date();
document.cookie="Name="FName"; domain=" + baseDomain + "; expires=" + expireAfter + "; path=/";
Upvotes: 1