Cookies - I delete them and they creep back up

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Mar 2009
Posts: 7
Reputation: EJM is an unknown quantity at this point 
Solved Threads: 0
EJM EJM is offline Offline
Newbie Poster

Cookies - I delete them and they creep back up

 
0
  #1
Apr 14th, 2009
Hi...
Can some one point out as to why my code does not work?
I've created some cookies like this:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var gotCookies = get_cookie(cookie_name);
  2. var exdate = new Date();
  3. exdate.setDate(exdate.getDate()+10);
  4. if(gotCookies != null)
  5. {
  6. //var gotCookie = document.cookie.split("; ");
  7. //var old_selection = gotCookie[0].split(", ");
  8. var new_selection = cbId;
  9. document.cookie = cookie_name+"="+gotCookies + ',<' + escape(new_selection) + ">,expires="+exdate.toGMTString() + ',path=/';
  10. }
  11. else
  12. {
  13. // Write a new cookie
  14. var new_selection = cbId;
  15. document.cookie = cookie_name + '=<'+escape(new_selection) + ">,expires="+exdate.toGMTString() + ',path=/';
  16. }

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.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function delete_cookie(name)
  2. {
  3. document.cookie = name+'="";expires=Fri, 14 Oct 2005 12:00:00 UTC;path=/';
  4. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Cookies - I delete them and they creep back up

 
0
  #2
Apr 14th, 2009
The delete_cookie() function is messing up the program. Try doing this:
  1. function delete_cookie(name) {
  2. var exp = new Date();
  3. var expdate = exp.setTime( exp.getTime() - 1 );
  4. document.cookie = name + "=; expires=" + expdate + "; path=/";
  5. }
Last edited by essential; Apr 14th, 2009 at 8:10 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 655 | Replies: 1
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC