最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How, with jQuery do I tell if a website visitor has been to the site before? - Stack Overflow

programmeradmin2浏览0评论

I want create a div container with a message for first time visitors to my site. Visitors will read it and click a 'Hide' button to dissapear it forever.

How is this done?

I want create a div container with a message for first time visitors to my site. Visitors will read it and click a 'Hide' button to dissapear it forever.

How is this done?

Share Improve this question edited Apr 16, 2009 at 14:58 moff 6,51333 silver badges30 bronze badges asked Apr 16, 2009 at 14:42 ZanderZander 2,6844 gold badges33 silver badges56 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

What about using the Cookie plugin for jQuery?

$.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.',
    secure: true // ...but only on a secure connection
});
$.cookie('the_cookie', null); // delete the session cookie

You can acplish this by:

  1. Setting a cookie.
  2. Storing the status in a session.

You can do 1. with JavaScript but also with PHP. 2. can only be acplished server-side with e.g. PHP.

This tutorial may be helpful: http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/

发布评论

评论列表(0)

  1. 暂无评论