簡體   English   中英

每次用戶進入我的網站時,如何更改我的年齡驗證以清除 cookies?

[英]How can I change my age verification to clear cookies every time a user enters my site?

我正在尋找一種解決方案,以便在每次用戶進入網站時顯示我的年齡檢查。 目前,它設置為每天為用戶顯示一次。 如果他們離開網站並在那天回來,我需要它再次顯示。 它位於 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();
   };

與其將其設置為 1 天后過期,不如將其設置為 0 秒后過期。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM