I want the code below to set the path to root, I understand I have to set / as the path value however this is not my code and I am not familiar with Javascript!
function setCookie(name, value, expires, path, domain, secure){
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
I have tried editing the code as below but have been unsuccessful.
setCookie(name, value, expires, path, domain, secure){
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path="/") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
I want the code below to set the path to root, I understand I have to set / as the path value however this is not my code and I am not familiar with Javascript!
function setCookie(name, value, expires, path, domain, secure){
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
I have tried editing the code as below but have been unsuccessful.
setCookie(name, value, expires, path, domain, secure){
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path="/") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
Share
Improve this question
asked Jan 24, 2014 at 9:58
HarryHarry
3712 gold badges5 silver badges15 bronze badges
1
- check out this link stackoverflow.com/questions/7551113/… – Mr.G Commented Jan 24, 2014 at 10:13
1 Answer
Reset to default 14change to this
function setCookie(name, value, expires, path, domain, secure){
document.cookie= name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
("; path=/") + //you having wrong quote here
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}