First, a quick introduction

A lightweight cookie plug-in, can read, write, delete cookies. The jquery.cookie.js configuration first contains the jQuery library file, and later contains the jquery.cookie.js library file.

Method of use

1. Add a new session cookie:

$.cookie(‘the_cookie’, ‘the_value’); Note: When the cookie is not valid, the cookie is created by default until the user closes the browser, so it is called

“Session Cookie”.

Create a cookie and set it to be valid for 7 days:

$.cookie(‘the_cookie’, ‘the_value’, { expires: 7 }); Note: When the validity time of the cookie is specified, the cookie created is called a “persistent cookie”.

Create a cookie and set the valid path of the cookie:

$.cookie(‘the_cookie’, ‘the_value’, { expires: 7, path: ‘/’ }); Note: By default, only the page on which the cookie is set can read the cookie. If you want one page to read another page set

Set the cookie, must set the cookie path. The path to the cookie is used to set the top-level directory from which the cookie can be read. Will this

The path is set as the root directory of the website, so that all pages can read cookies from each other (generally do not set this to prevent conflicts).

4. Read the cookie:

$.cookie(‘the_cookie’); // Cookie exists => ‘the_value’ $. Cookie (‘not_existing’); // Cookie does not exist => null

5. To delete the cookie, pass NULL as the value of cookie:

$.cookie(‘the_cookie’, null); ———- the explanation of the relevant parameters

1).expires: 365

Define the valid time of the cookie, either as a number (in days from the time the cookie was created) or as a Date pair

Elephant. If omitted, the cookie created is a session cookie and will be deleted when the user exits the browser.

2).path: ‘/’

By default, only the page on which the cookie is set can read the cookie.

Define a valid path to the cookie. By default, the value of this parameter is the path of the Web page on which the cookie was created (the behavior of standard browsers).

If you want to access the cookie throughout the site you need to set the valid path like this: path: ‘/’. If you want to delete a definition

$.cookie(‘the_cookie’, null, $.cookie(‘the_cookie’, null), $.cookie(‘the_cookie’, null), $.cookie(‘the_cookie’, null), $.cookie(‘the_cookie’, null)

{ path: ‘/’ }); . domain: ‘example.com’

Default: Domain owned by the page on which the cookie was created.

3).secure: true

Default: false. If true, the cookie is transmitted using a secure protocol (HTTPS).

4).raw: true

Default: false.

By default, cookies are automatically encoded and decoded when they are read and written (using EncodeUricomponent encoding,

DecodeURIComponent). To turn this off, set raw: true.

</ span > </ p > < p style =" margin:0px; padding :0px; } .ying{ background:#000; } .cang{ position: relative; } .cang a{ display: block; height:80px; background: url("images/9.jpg") no-repeat 50% 0; } @media screen and (max-width: 1200px) { .cang a{ background: url("images/01.jpg") no-repeat 50% 0; } } .ca{ height: 20px; width: 20px; Background: RGB (45,45,45); cursor: pointer; position: absolute; right: 100px; top: 5px; font-weight: bold; font-size: 14px; color: #FFF; opacity: .3; text-align: center; } </style>

</head>

<body>

<div class="ying"> <div class="cang"> <a href="#"> <div class="ca"> <span>x</span> </div> </a> </div> </div> <script SRC ="js/jquery1.8.3.min.js"></script> <script SRC ="js/ cookey.js "></script> <script> function detectDevice(){var cang=screen.availWidth; if(cang>1200){ $("html").addClass("desktop"); } } detectDevice(); function caAd(){ $(".ca").click(function(){ $(".ying").fadeOut("show"); setCookie("isCa","1",1) }); if(! getCookie("isCa")){ $(".ying").show(); } } caAd(); </script>

</body>

</html>