JQuery操作cookies
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
JQuery操作cookies的更多相关文章
- 使用jQuery操作Cookies的实现代码
Cookie是由服务器端生成,发送给User-Agent(一般是浏览器),浏览器会将Cookie的key/value保存到某个目录下的文本文件内,下次请求同一网站时就发送该Cookie给服务器(前提是 ...
- 使用jQuery操作Cookies
转载自: https://www.cnblogs.com/yonge/articles/2698106.html Cookies是一种能够让网站服务器把少量数据储存到客户端的硬盘或内存,或是从客户端的 ...
- 关于jQuery的cookies插件2.2.0版设置过期时间的说明
欢迎转载,转载请注明作者RunningOn jQuery应该是各位用JavaScript做web开发的常用工具了,它有些插件能非常方便地操作cookie. 不过非常让人郁闷的是,网上几乎所有人对于这些 ...
- Jquery操作cookie,实现简单的记住用户名的操作
一.jquery.cookie.js介绍 jquery.cookie.js是一个基于jquery的插件,一个轻量级的cookie 插件,可以读取.写入.删除 cookie. jquery.cook ...
- jQuery 操作cookie保存用户浏览信息
使用jQuery操作cookie之前需要引入jQuery的一个cookie小组件js,代码如下: /* jQuery cookie plugins */jQuery.cookie ...
- 13-1 jquery操作cookie
jQuery之cookie操作 Cookies 定义:让网站服务器把少量数据存储到客户端的硬盘或内存,从客户端的硬盘里读取数据的一种技术; 下载与引入:jquery.cookie.js基于jquery ...
- 对jquery操作复选框
摘要:jquery操作复选框.使用更简洁易懂,思路清晰,逻辑更明了,很实用 <!DOCTYPE html> <html> <head> <meta chars ...
- jquery操作表格 合并单元格
jquery操作table,合并单元格,合并相同的行 合并的方法 $("#tableid").mergeCell({ cols:[X,X] ///参数为要合并的列}) /** * ...
- input jquery 操作
本文章主要为了总结开发常用的input等常见html的jquery操作,不是为了展示自己多么菜,只为了积累知识,勿喷!!!不断更新中 $(function () { $("input[nam ...
随机推荐
- 奶瓶(beini)破解无线密码流程:安装、抓包、从虚拟机(VMware)拷贝握手包(拷贝到硬盘、U盘)、跑包
1. 环境 1). Windows 7 64位版本 2). VMware 9.0.2版本 3). 奶瓶1.2.3版本(beini-1.2.3.iso) 2. 安装 2.1 安装方式一 将beini-1 ...
- Atitit jdbc 处理返回多个结果集
Atitit jdbc 处理返回多个结果集 Statement接口提供了三种执行SQL语句的方法: executeQuery.executeUpdate和execute.使用哪一个方法由SQL语句所 ...
- Atitit 跨平台的系统截图解决方案
Atitit 跨平台的系统截图解决方案 1.1. Nodes js 方案desktop-screenshot进行系统截图1 1.2. Win 方案,autoit dsl,可能不跨台1 1.3. Jav ...
- spark repartition
https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/spark-rdd-partitions.html http://s ...
- 深入理解Java中的逃逸分析
在Java的编译体系中,一个Java的源代码文件变成计算机可执行的机器指令的过程中,需要经过两段编译,第一段是把.java文件转换成.class文件.第二段编译是把.class转换成机器指令的过程. ...
- 每日英语:The Benefits of a Better Men's T-Shirt
"I WEAR A T-shirt and jeans every single day," said Erik Schnakenberg, 30, co-founder of t ...
- Python fabric实践操作
前面学习了理论,下面该练练手了.两台机器:10.1.6.186.10.1.6.159.fabric部署在10.1.6.186上面. 1 执行一个简单的task任务,显示两台机器的/home/guol ...
- 【Mysql】Fedora下 Mysql 安装及配置
1.安装 Mysql Server # yum install mysql mysql-server 可以到mysql官网去下载,我下载的是通用版本.你需要下载下面四个文件就可以了. mysql-cl ...
- LeetCode: Search a 2D Matrix 解题报告
Search a 2D Matrix Write an efficient algorithm that searches for a value in an m x n matrix. This m ...
- 【TensorFlow】TF-tf.nn.dropout
官方的接口是这样的 tf.nn.dropout(x, keep_prob, noise_shape=None, seed=None, name=None) 根据给出的keep_prob参数,将输入te ...