0

Hi...
Can some one point out as to why my code does not work?
I've created some cookies like this:

var gotCookies = get_cookie(cookie_name);
var exdate = new Date();
exdate.setDate(exdate.getDate()+10);
if(gotCookies != null)
{
    //var gotCookie = document.cookie.split("; ");         
    //var old_selection = gotCookie[0].split(", ");
    var new_selection = cbId;
    document.cookie = cookie_name+"="+gotCookies + ',<' + escape(new_selection) + ">,expires="+exdate.toGMTString() + ',path=/';
}
else
{
    // Write a new cookie
    var new_selection = cbId;
    document.cookie = cookie_name + '=<'+escape(new_selection) + ">,expires="+exdate.toGMTString() + ',path=/';
}

and when I run the "delete cookies" they don't go away, only after I close the browser. I realize I set a 10 day life span,but if you delete them shouldn't they go away? Here is how I delete them.

function delete_cookie(name) 
        {  
           document.cookie = name+'="";expires=Fri, 14 Oct 2005 12:00:00 UTC;path=/'; 
        }
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by essential
0

The delete_cookie() function is messing up the program. Try doing this:

function delete_cookie(name) { 
   var exp = new Date();
   var expdate = exp.setTime( exp.getTime() - 1 );
document.cookie = name + "=; expires=" + expdate + "; path=/";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.