Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to delete Cookie before redirect to other page in javascript?
    primarykey
    data
    text
    <p>I have this code to set up and check a cookie, and before a redirect (if the user click on the cancel button) I need to unset or delete the cookie.</p> <pre><code>function getCookie(c_name) { if (document.cookie.length &gt; 0) { c_start = document.cookie.indexOf(c_name + "=") if (c_start != -1) { c_start = c_start + c_name.length + 1 c_end = document.cookie.indexOf(";", c_start) if (c_end == -1) c_end = document.cookie.length return unescape(document.cookie.substring(c_start, c_end)) } } return ""; } function setCookie(c_name, value, expiredays) { var exdate = new Date() exdate.setDate(exdate.getDate() + expiredays) document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toGMTString()) } function checkCookie() { var todaysdate = new Date() var day = todaysdate.getDay() switch (day) { case 1: day = "Monday" break case 2: day = "Tuesday" break case 3: day = "Wednesday" break case 4: day = "Thursday" break case 5: day = "Friday" break case 6: day = "Saturday" break case 0: day = "Sunday" break } var thedate = getCookie('thedate') if (thedate != null &amp;&amp; thedate != "") { if (day == thedate) {} else { alert('') } } else { thedate = day if (thedate != null &amp;&amp; thedate != "") { setCookie('thedate', thedate, 365) // alert('dsadasdasdasdasdasdasd') var answer = confirm("Please click on OK to continue loading my page, or CANCEL to be directed to the Yahoo site.") if (!answer) { window.location = "http://www.yahoo.com/"; } } } } </code></pre> <p>How to unset the cookie <code>c_name</code>? </p> <p>I'm sure it's something easy, however I am not able to unset this cookie.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload