function delete_cookie()

I would like to have a cooke removed by expiring the cookie.

code.js contains this method:

function delete_cookie()
             var expireDate = new Date ( );              // current date & time
              expireDate.setTime ( expireDate.getTime() - 1 );
              document.cookie date = expireDate.toGMTString();

it is called when the button is clicked in details.htm.  this is the html part of the button:

<input type="button" value="Clear Cookie" onclick="delete_cookie()">

Not sure about the last line in the function.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

last line should be:
document.cookie ="cookieName=; expires=" + expDate.toGMTString();


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
also you can use date in the past, without create date:

expires=Thu, 01-Jan-70 00:00:01 GMT

for example so:
function deleteCookie(cookieName)
      document.cookie = cookieName + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
ZvonkoSystems architectCommented:
The dashes and the year are wrong.

Better use this:
     document.cookie=cookieName+"=;expires=Tue, 01 Jan 1970";

ZvonkoSystems architectCommented:
Sorry, the correct day is Thu, but it delete the cookie anyway. You can write any day of the week, for example: Mon,
But to be correct it should be:

     document.cookie=cookieName+"=;expires=Thu, 01 Jan 1970";

ZvonkoSystems architectCommented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.