การคัดลอกรหัสมีดังนี้:
-
เครื่องมือคุกกี้
วิธีใช้:
// บันทึกค่า
var value = "7 วัน";
Tools.Cookie ("วัน", ค่า, {หมดอายุ: 7});
// รับค่า
var v = tools.cookie ("วัน");
-
tools.cookie = ฟังก์ชั่น (ชื่อ, ค่า, ตัวเลือก) {
if (typeof value! = 'undefined') {// ชื่อและค่าที่กำหนดให้ตั้งค่าคุกกี้
ตัวเลือก = ตัวเลือก || {};
if (value === null) {
ค่า = '';
ตัวเลือก expires = -1;
-
var expires = '';
if (opptions.expires
&& (ตัวเลือก typeof.expires == 'number' || opotions.expires.togmtstring)) {
วันที่ var;
if (typeof options.expires == 'number') {
วันที่ = วันที่ใหม่ ();
date.settime (date.getTime ()
+ (ตัวเลือก expires * 24 * 60 * 60 * 1000));
} อื่น {
วันที่ = ตัวเลือกที่ว่างเปล่า;
-
Expires = ';
// คุณลักษณะ,
// max-age ไม่ใช่
// สนับสนุนโดย IE
-
var path = ตัวเลือก?
var domain = opotions.domain? ';
var secure = opotions.secure?
document.cookie = [ชื่อ, '=', encodeuricomponent (ค่า), หมดอายุ
เส้นทาง, โดเมน, ปลอดภัย] .oin ('');
} else {// ชื่อที่กำหนดเท่านั้นรับคุกกี้
var cookievelue = null;
if (document.cookie && document.cookie! = '') {
var cookies = document.cookie.split (';');
สำหรับ (var i = 0; i <cookies.length; i ++) {
var cookie = jQuery.trim (คุกกี้ [i]);
// สตริงคุกกี้นี้เริ่มต้นด้วยชื่อที่เราต้องการหรือไม่?
if (cookie.substring (0, name.length + 1) == (ชื่อ + '=')) {
CookieVieValue = decodeuricomponent (คุกกี้
.SubString (ชื่อความยาว + 1));
หยุดพัก;
-
-
-
กลับมาทำอาหาร;
-
-