📌  相关文章
📜  检查cookie是否存在js - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:10.743000             🧑  作者: Mango

代码示例1
document.cookie = "hacker=anthony; SameSite=None; Secure";

   function checkACookieExists() {
       if (document.cookie.split(';').some((item) => item.trim().startsWith('hacker='))) {
            const output = document.getElementById('a-cookie-existence')
              output.textContent = '> The cookie "hacker" exists'
            }
        }

        function clearOutputACookieExists() {
            const output = document.getElementById('a-cookie-existence')
            output.textContent = ''
        }