Home > Web Front-end > JS Tutorial > body text

Javascript reads background cookie code_javascript skills

WBOY
Release: 2016-05-16 19:01:13
Original
878 people have browsed it

The following is the regular method I use to get cookies, including single value and multi-value:

Copy code The code is as follows:

/************************************************
Parameter description:
sMainName Cookie name
sSubName Cookie subkey name, leave blank to indicate single value Cookie
************************ ****************************/
function GetCookie(sMainName, sSubName)
{
var re = new RegExp(sMainName (sSubName ? "=" sSubName : "") "= (.*?);", "i");
return re.test(unescape(document.cookie)) ? RegExp["$1"] : "";
}


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template