-1

I think the problem is not only the exp.date but the startup, every time I refresh the page the cookie bar reappears. why won't it save the cookie?

cookieScriptLoadJavaScript = function (d, b) {
    var c = document.getElementsByTagName("head")[0],
        a = document.createElement("script");
    a.type = "text/javascript", a.src = d, b != undefined && (a.onload = a.onreadystatechange =     function () 
    {
        (!a.readyState || /loaded|complete/.test(a.readyState)) && (a.onload =      a.onreadystatechange = null, c && a.parentNode && c.removeChild(a), a = undefined, b())
    }), c.insertBefore(a, c.firstChild)
}, 

InjectCookieScript = function () {


cookieScriptCreateCookie = function (n, t, i) {
        var u = "",
            r, f;
        i && (r = new Date, r.setTime(r.getTime()), u = "; expires=" + r.toGMTString()), f = "", cookieScriptDomain != "" && (f = "; domain=" + cookieScriptDomain), document.cookie = n + "=" + t + u + f + "; path=/"
    }, 
user1
  • 39
  • 1
  • 8

1 Answers1

1

You obviously need the change r. If you want to set the cookie for 2 days permanently you may want to use this:

r.setDate(r.getDate() + 2);

But I recommend you pass it as a variable to your function. That way you keep your code dynamic. Your code could look like:

cookieScriptCreateCookie = function (n, t, i, q) {
        var u = "",
            r, f;
        i && (r = new Date, r.setDate(r.getDate() + q), u = "; expires=" + r.toGMTString()), f = "", cookieScriptDomain != "" && (f = "; domain=" + cookieScriptDomain), document.cookie = n + "=" + t + u + f + "; path=/"
    }, 
Yorick de Wid
  • 859
  • 11
  • 19