关于JQUERY插件cookies

showrock 发布于 2010/07/04 13:59
阅读 2K+
收藏 2

怎么浏览器关了就消失了?神奇死了啊,怎么会这样的呢

有效期怎么设置的?

加载中
0
大猪
大猪

你浏览器设置的问题吧

0
s
showrock

FF也是一样的情况,只要关掉浏览器再开,cookie就是空的

这个例子里也没有关于时间的设置啊,。。。。

//set 
$.cookies.set( 'sessid', 'dh3tr62fghe' ); //A cookie by the name 'sessid' now exists with the value 'dh3tr62fghe' 
 
//get 
var sessid = $.cookies.get( 'sessid' ); //Variable 'sessid' now holds the value 'dh3tr62fghe' 
 
//delete 
$.cookies.del( 'sessid' ); //The cookie named 'sessid' has been deleted. 
 
//test 
if( $.cookies.test() ) 
{ 
  //browser is accepting cookies 
} 
 
 
//JSON 
var jimData = {id: 1, name: 'jim'}; 
$.cookies.set( 'userdata', jimData ); //A cookie by the name 'userdata' now exists with a serialized copy of jimData 
 
var userData = $.cookies.get( 'userdata' ); //A variable named 'userData' now holds the unserialized object--should be identical to the variable 'jimData' 
 
 
//jQuery Extensions 
$( 'input.store' ).cookify(); //Inputs with class of 'store' are written to a cookie named after the input 
 
$( 'input.store' ).cookieFill(); //Inputs with class of 'store' are filled with the value of cookies with matching names 
 
$( 'input.store' ).cookieBind(); //Inputs with class of 'store' are filled with the value of cookies with matching names and whenever they change the cookie will be updated
0
s
showrock

楼上你跟我说的不是一个啊,我用的是这个

http://www.oschina.net/p/cookies

0
红薯
红薯

var newOptions = {
domain: '*.mydomain.com',
path: '/somedir',
expiresAt: new Date( 2011, 1, 1 ),
secure: true
}
jaaulde.utils.cookies.set('myCookie', 'myValue', newOptions);

0
s
showrock

谢谢楼上~

请问本地是localhost

domain应该如何设置?

0
s
showrock

唉。。。

domain: '127.0.0.1‘

解决了

0
红薯
红薯

引用来自#8楼“showrock”的帖子

谢谢楼上~

请问本地是localhost

domain应该如何设置?

像你这种情况,可以不设置 domain

0
s
showrock

确实,不设置是对的,谢谢

返回顶部
顶部