向jquery cookie添加多行 [英] adding more than one rows to jquery cookies

查看:146
本文介绍了向jquery cookie添加多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码检查Cookie可用性并创建新Cookie。如果cookie存在,那么我需要再向现有cookie添加一行。



函数addUsers(userID,userName){

var userInfo = [];

userInfo [0] = userID;

userInfo [1] = userName;

var cookieName ='cUserInfo';



if ($ .cookie(cookieName)){

//需要在现有的cookie中添加另一行

}

else {

$ .cookie(cookieName,escape(userInfo .join(',')),{expires:1});

}

}



请告知如何阅读所有Cookie。



提前致谢。

I am using following code to check cookie availability and create a new cookie. If cookie exists then I need to one more row to the existing cookie.

function addUsers(userID, userName) {
var userInfo = [];
userInfo[0] = userID;
userInfo[1] = userName;
var cookieName = 'cUserInfo';

if ($.cookie(cookieName)) {
//need to add another row to the existing cookie
}
else {
$.cookie(cookieName, escape(userInfo .join(',')), { expires: 1 });
}
}

Please advise how to read all set of cookies as well.

Thanks in advance.

推荐答案

.cookie(cookieName)){

//需要在现有cookie中添加另一行

}

else {
.cookie(cookieName)) {
//need to add another row to the existing cookie
}
else {


.cookie(cookieName,escape(userInfo) .join(',')),{expires:1});

}

}



请告知如何阅读所有饼干。



提前致谢。
.cookie(cookieName, escape(userInfo .join(',')), { expires: 1 });
}
}

Please advise how to read all set of cookies as well.

Thanks in advance.


这篇关于向jquery cookie添加多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆