API - jQuery之操作cookie(转)
Installation
Include script after the jQuery library (unless you are packaging scripts somehow else):
- <script src="/path/to/jquery.cookie.js"></script>
Usage
Create session cookie:
- $.cookie('the_cookie', 'the_value');
Create expiring cookie, 7 days from then:
- $.cookie('the_cookie', 'the_value', { expires: 7 });
Create expiring cookie, valid across entire page:
- $.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
Read cookie:
- $.cookie('the_cookie'); // => 'the_value'
- $.cookie('not_existing'); // => null
Delete cookie by passing null as value:
- $.cookie('the_cookie', null);
Options
- expires: 365
Define lifetime of the cookie. Value can be a Number (which will be interpreted as days from time of creation) or a Date object. If omitted, the cookie is a session cookie.
- path: '/'
Default: path of page where the cookie was created.
Define the path where cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire page use path: '/'. If you want to delete a cookie with a particular path, you need to include that path in the call.
- domain: 'example.com'
Default: domain of page where the cookie was created.
- secure: true
Default: false. If true, the cookie transmission requires a secure protocol (https).
- raw: true
Default: false.
By default the cookie is encoded/decoded when creating/reading, using encodeURIComponent/decodeURIComponent. Turn off by setting raw: true.
官网地址:http://plugins.jquery.com/project/Cookie
API - jQuery之操作cookie(转)的更多相关文章
- Jquery操作cookie,实现简单的记住用户名的操作
一.jquery.cookie.js介绍 jquery.cookie.js是一个基于jquery的插件,一个轻量级的cookie 插件,可以读取.写入.删除 cookie. jquery.cook ...
- jquery.cookie.js 操作cookie实现记住密码功能的实现代码
jquery.cookie.js操作cookie实现记住密码功能,很简单很强大,喜欢的朋友可以参考下. 复制代码代码如下: //初始化页面时验证是否记住了密码 $(document).ready( ...
- 关于Jquery 操作Cookie 取值错误
使用JQuery操作cookie时 发生取的值不正确的问题: 结果发现cookie有四个不同的属性: 名称,内容,域,路径 $.cookie('the_cookie'); // 读取 cookie $ ...
- jquery操作cookie {分享}
web开发过程中如果网站有一部分信息是存储在cookie中并与服务器交互的话,那么前台有时就会遇到需要对cookie中信息进行操作的情况,一个最典型的例子就是在前台判断用户是否登录过当前所访问的网站. ...
- Jquery操作Cookie取值错误的解决方法
使用JQuery操作cookie时 发生取的值不正确,结果发现cookie有四个不同的属性,分享下错误的原因及解决方法. 使用JQuery操作cookie时 发生取的值不正确的问题: 结果发现coo ...
- jquery.cookie 使用文档,$.cookie() 文档教程, js 操作 cookie 教程文档。
jquery.cookie 使用文档,$.cookie() 文档教程, js 操作 cookie 教程文档. jquery.cookie中的操作: jquery.cookie.js是一个基于jquer ...
- 【转载】使用Jquery操作Cookie对象
Cookies是一种能够让网站服务器把少量数据储存到客户端的硬盘或内存,或是从客户端的硬盘读取数据的一种技术.jQuery是一个封装好的JavaScript库,使用jQuery可以极大地简化了Java ...
- 本地使用js或jquery操作cookie在谷歌浏览器chrome中不生效
一般是在本地调试cookie,无论使用jquery cookie插件还是js原生态cookie方法,在谷歌浏览器chrome中都不生效,这是什么原因? 原因是: chrome不支持js在本地操作coo ...
- jQuery 操作cookie保存用户浏览信息
使用jQuery操作cookie之前需要引入jQuery的一个cookie小组件js,代码如下: /* jQuery cookie plugins */jQuery.cookie ...
随机推荐
- ClickOnce部署winform
1.完成winform程序. 示例: 2.项目->属性->发布. 有关ftp在iis中的配置,请参考:IIS中添加ftp站点 :url也需在iis中配置.flashfxp中显示ftp成功 ...
- 到底二级域名和一级域名哪个更利于SEO
到底二级域名和一级域名哪个更利于SEO呢?本文是从百度官方转载详细的介绍:二级域名和一级域名的区别,请各位认真阅读. 二级域名和子域名的区别可以通过以下3点来解读: 一,二级域名的特点 搜索引擎往往将 ...
- LLDP协议、STP协议 笔记
参考: 数据链路层学习之LLDP 生成树协议 LLDP协议.STP协议 笔记 LLDP 提出背景: 随着网络技术的发展,接入网络的设备的种类越来越多,配置越来越复杂,来自不同设备厂商的设备也往往会增加 ...
- ZOJ 3329 One Person Game (经典概率dp+有环方程求解)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3329 题意:现在有三个骰子,分别有k1,k2和k3面,面上的点就是1~ki ...
- ACMG遗传变异分类标准与指南
2015年,美国权威机构——美国医学遗传学与基因组学学会(ACMG)编写和发布了<ACMG遗传变异分类标准与指南>.为帮助我国医疗工作者和遗传咨询从业者更好地理解ACMG遗传变异分类标准. ...
- shell 清空指定大小的日志文件
#!/bin/bash # 当/var/log/syslog大于68B时 if ! [ -f /var/log/syslog ] then echo "file not exist!&quo ...
- c++ primer plus 第二章 课后题答案
#include<iostream> using namespace std; int main() { cout << "My name is Jiantong C ...
- Android 上传大文件
最近工作需要实现使用 Android 手机上传图片的功能, 参考了网络上的很多资料, 不过网络上的代码都仅仅适合上传较小的文件, 当上传较大文件时(我在自己的测试机器上发现是 2M 左右), 就会因为 ...
- [转]UTF-8网页中的头部部分多出一行空白
最近做php开发,我自己的习惯都是用utf-8编码,有时候却在网页顶部多了一个空白行,甚至引起了式样的错乱,后来google到这么一篇文 章,彻底解决问题UTF-8的BOM问题通常情况下,使用Wind ...
- Jersey 2.x 前言和约定的文本格式
这是Jersey 2.x 的用户指南.我们极力将它能与我们新增的功能保持一致.当阅读本指南,作为补充,也请移步至Jersey API documentation查看 Jersey 的特性和 API. ...