js cookie操作
//写Cookie
function writeCookie(name, value)
{
var expire = new Date();
expire.setFullYear(expire.getFullYear() + 20);
expire = '; expires=' + expire.toGMTString();
document.cookie = name + '=' + escape(value) + expire;
}
// 读取Cookie
function readCookie(name)
{
var cookieValue = '';
var search = name + '=';
if (document.cookie.length > 0)
{
var offset = document.cookie.indexOf(search)
if (offset != -1)
{
offset += search.length;
var end = document.cookie.indexOf(';', offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end));
}
}
return cookieValue;
}
// 读取Cookie
function readCookieCn(name)
{
var cookieValue = '';
var search = name + '=';
if (document.cookie.length > 0)
{
var offset = document.cookie.indexOf(search)
if (offset != -1)
{
offset += search.length;
var end = document.cookie.indexOf(';', offset);
if (end == -1) end = document.cookie.length;
cookieValue = decodeURI(document.cookie.substring(offset, end));
}
}
return cookieValue;
}
js cookie操作的更多相关文章
- js cookie 操作 封装
pCookie.js (function(){ var PotatogCookie = {}; //设置cookie PotatogCookie.set = function(key, value, ...
- js cookie 操作
<html> <head> <meta charset="utf-8"> <title>Javascript cookie</ ...
- js简单操作Cookie
贴一段js简单操作Cookie的代码: //获取指定名称的cookie的值 function getCookie(objName) { var arrStr = document.cookie.spl ...
- js中cookie操作
js中操作Cookie的几种常用方法 * cookie中存在域的概念,使用path和domain区分: * 在同一域中的set和del可以操作同一名称的cookie,但不在同一域中的情况下,则set无 ...
- js 判断js函数、变量是否存在 JS保存和删除cookie操作,判断cookie是否存在的方法
//是否存在指定函数 function isExitsFunction(funcName) { try { if (typeof(eval(funcName)) == " ...
- JS封装cookie操作函数实例(设置、读取、删除)
本文实例讲述了JS封装cookie操作函数.分享给大家供大家参考,具体如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ...
- js实用方法记录-简单cookie操作
js实用方法记录-简单cookie操作 设置cookie:setCookie(名称,值,保存时间,保存域); 获取cookie:setCookie(名称); 移除cookie:setCookie(名称 ...
- Jquery和js实现cookie操作手机浮层广告;附加:js获取、添加、删除cookie
1.jquery cookie包实现手机上的浮层广告 <span style="font-size:18px;">$(document).ready(function( ...
- nw.js的cookie操作
在实战中,我遇到nw.js cookie一个奇怪的现象. 当我写入cookie(非httponly)后,关闭nw.js.然后再打开nw.js发现cookie没有写入成功.经过摸索,发现 nw.js的c ...
随机推荐
- 如何选择分类器?LR、SVM、Ensemble、Deep learning
转自:https://www.quora.com/What-are-the-advantages-of-different-classification-algorithms There are a ...
- OVS ARP Responder – Theory and Practice
Prefix In the GRE tunnels post I’ve explained how overlay networks are used for connectivity and ten ...
- 修改数据库mysql字符编码为UTF8
Mysql数据库是一个开源的数据库,应用非常广泛.以下是修改mysql数据库的字符编码的操作过程. 步骤1:查看当前的字符编码方法 mysql> show variables like'char ...
- 【字体区别】Serif和Sans Serif
[字体区别]Serif和Sans Serif 在西方国家罗马字母阵营中,字体分为两大种类:Sans Serif和Serif,打字机体虽然也属于Sans Serif,但由于是等宽字体,所以另外独立出Mo ...
- call & apply
对于apply和call两者在作用上是相同的:这两个方法通常被用来类的继承和回调函数.但两者在参数上有区别的.call函数和apply方法的第一个参数都是要传入给当前对象的对象,及函数内部的this. ...
- Apahce的虚拟用户认证及server-status页
一.Apache虚拟用户认证配置 编辑配置文件加入如下内容: <Directory "/www/htdoc/fin"> Options None AllowOverri ...
- scala言语基础学习五
extends override 和super方法 override field 父类不是val对象不能覆盖field isInstanceOf和asInstanceOf(isInstanceOf是用 ...
- URAL 1218 Episode N-th: The Jedi Tournament(强连通分量)(缩点)
Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Jedi Kni ...
- Foundation框架 - 快速创建跨平台的网站页面原型
API参考:http://foundation.zurb.com/docs/ 作为网页设计和开发人员,我们面临着以下几个严峻的问题: 每天,人们用来上网的设备种类和数量都在不断上升. 为每种设备设计开 ...
- pyCharm使用
1.修改文件和代码模板 修改文件头 2.显示行号