Javascript 我如何更改我的年龄验证以在每次用户进入我的网站时清除cookies?

Javascript 我如何更改我的年龄验证以在每次用户进入我的网站时清除cookies?,javascript,cookies,Javascript,Cookies,我正在寻找一个解决方案,我的年龄检查显示每次用户进入该网站。目前,它被设置为每天为用户显示一次。如果他们离开网站,那天回来,我需要它再次显示。它在Shopify上 if ((today.getTime() - theirDate.getTime()) < 0) { window.location = 'http://google.com'; //enter domain url where you would like the underaged visit

我正在寻找一个解决方案,我的年龄检查显示每次用户进入该网站。目前,它被设置为每天为用户显示一次。如果他们离开网站,那天回来,我需要它再次显示。它在Shopify上

           if ((today.getTime() - theirDate.getTime()) < 0) {
     window.location = 'http://google.com'; //enter domain url where you would like the underaged visitor to be sent to.
   } else {
     var days = 1; //number of days until they must go through the age checker again.
     var date = new Date();
     date.setTime(date.getTime()+(days*24*60*60*1000));
     var expires = "; expires="+date.toGMTString();
     document.cookie = 'isAnAdult=true;'+expires+"; path=/";
     location.reload();
   };
if((today.getTime()-theirDate.getTime())<0){
window.location=http://google.com“;//输入您希望未成年访问者发送到的域url。
}否则{
var days=1;//必须再次通过年龄检查器的天数。
变量日期=新日期();
date.setTime(date.getTime()+(天*24*60*60*1000));
var expires=“;expires=“+date.togmString();
document.cookie='isAnAdult=true;'+expires+“path=/”;
location.reload();
};

与其将其设置为在一天内过期,不如将其设置为在0秒后过期。

会话cookie。您希望cookie立即过期,要求用户在每次进入站点时验证其年龄。