Im taking the domain from the HTML of the page using jQuery:
domainUrl = $("p.domain").text();
for the purposes of testing:
<p class="domain">.vl3.co.uk</p>
Which is also the domain Im testing the script on.
This then give an alert containing the correct domain:
alert(domainUrl);
I want to the use that variable to set the domain in a cookie:
set_cookie('visible', 'no', 2020, 1, 1, '/', '+domainUrl+');
Here is the set cookie function:
function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) {
var cookie_string = name + "=" + escape ( value );
if ( exp_y ) {
var expires = new Date ( exp_y, exp_m, exp_d );
cookie_string += "; expires=" + expires.toGMTString();
}
if ( path )
cookie_string += "; path=" + escape ( path );
if ( domain )
cookie_string += "; domain=" + escape ( domain );
if ( secure )
cookie_string += "; secure";
document.cookie = cookie_string;
}
Why doesnt the cookie domain get set?
I think the problem is how im using the domainUrl variable when setting the cookie?