如何使用jQuery告诉网站访问者之前是否访问过该网站?

Zan*_*der 5 javascript cookies jquery

我想创建一个div容器,其中包含第一次访问我网站的消息.访问者将阅读它并单击"隐藏"按钮以永久消除它.

这是怎么做到的?

mof*_*off 8

那么为jQuery 使用Cookie插件呢?

$.cookie('the_cookie', 'the_value'); // Create a session cookie ("the_cookie") and set its value to "the_value"
$.cookie('chocolate_chip_cookie', 'the_value', { // create a cookie with all available options
    expires: 7, // expires in seven days
    path: '/', // accessible from the whole site...
    domain: 'jquery.com',
    secure: true // ...but only on a secure connection
});
$.cookie('the_cookie', null); // delete the session cookie
Run Code Online (Sandbox Code Playgroud)