jquery.cookie.js使用
2023-09-14 09:01:20 时间
1、下载jquery.cookie.js 官网:http://plugins.jquery.com/cookie/ 或 http://pan.baidu.com/s/1mgynA8g 2、使用方法 复制代码 $.cookie('the_cookie'); // 获得cookie $.cookie('the_cookie', 'the_value'); // 设置cookie $.cookie('the_cookie', 'the_value', { expires: 7 }); //设置带时间的cookie $.cookie('the_cookie', '', { expires: -1 }); // 删除 $.cookie('the_cookie', null); // 删除 cookie $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});//新建一个cookie 包括有效期 路径 域名等 复制代码 3、测试,HTML页中写一个cookie值,然后用ajax调用一个nginx请求,nginx里用LUA获取到这个cookie值再返回给HTML页最后alert出来。 HTML页 复制代码 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> <script type="text/javascript" src="jquery.cookie.js"></script> <script> $.cookie('uid', 'dsideal'); </script> </head> <body> <p> <input type="button" value="test" onclick="test();" /> </p> </body> <script> function test() { $.ajax({ type : "GET", async : false, url : "http://10.10.3.205/getCookie", success : function(res) { alert(res); } }); } </script> </html> 复制代码 nginx location /getCookie{ content_by_lua ' ngx.header.content_type = "text/plain;charset=utf-8" ngx.say(ngx.var.cookie_uid) '; }
相关文章
- jQuery分页插件(jquery.page.js)的使用
- JS框架_(JQuery.js)高德地图api
- jQuery选择器案例之——index.js
- JS魔法堂:jQuery.Deferred(jQuery1.5-2.1)源码剖析
- 理解JS回调函数
- 到浏览器顶部的获取js和jquery
- JQuery-zTree.js使用范例
- js和jquery获取父级元素、子级元素、兄弟元素的方法{转}
- js生成二维码的jquery组件–qrcode
- 移动端滚动加载-----jQuery 和 原生JS
- Atitit.js javascript异常处理机制与java异常的转换.js exception process Voae
- paip.提升效率--数据绑定到table原理和流程Angular js jquery实现
- js对象扁平化:Javascript对象进行扁平化处理
- js_jQuery【下拉菜单联动dom操作】
- 原生js与jQuery显示隐藏div的几种方法
- JS和jquery加载的区别
- js-jquery-003-条形码-二维码【QR码】
- js-jquery-对象与JSON字符串互相转换
- python web py入门(57)- jQuery - 多个JS代码的文件
- js和jquery获取文档对象以及滚动条位置
- 说说js中使用for in遍历数组存在的bug
- jquery.js和jquery.min.js的区别介绍