如何使用javascript将cookie添加到自定义模式

如何使用javascript将cookie添加到自定义模式,javascript,html,jquery,cookies,local-storage,Javascript,Html,Jquery,Cookies,Local Storage,我需要将cookies添加到我的模式弹出窗口中,以便用户在所有项目网页中的每个浏览器会话中只能看到一次cookies 下面是HTML代码 <div id="popup"> <div class="modalconent"> <button id="button"><span class="close">&times;</spa

我需要将cookies添加到我的模式弹出窗口中,以便用户在所有项目网页中的每个浏览器会话中只能看到一次cookies

下面是HTML代码

    <div id="popup">
    <div class="modalconent">

      <button id="button"><span class="close">&times;</span></button>

         <h1></h1>

        <p>Some text in the Modal..</p>
    </div>
</div> 
这是我的css代码:

#modal {
    position: fixed;
    font-family: Arial, Helvetica, sans-serif;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    height: 100%;
    width: 100%;
}
.modalconent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 80%;
    padding: 20px;
}

a) 默认情况下,您应该隐藏模式,并在cookie不存在时显示它,而不是相反b)没有处理cookie的JS代码;请先进行适当的研究,然后在问题中添加您尝试过的代码,以防您陷入困境,并准确地告诉我们失败的原因。这是否回答了您的问题?
#modal {
    position: fixed;
    font-family: Arial, Helvetica, sans-serif;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    height: 100%;
    width: 100%;
}
.modalconent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 80%;
    padding: 20px;
}