jquery cookie设置值为布尔值true [英] jquery cookie set value to boolean true

查看:649
本文介绍了jquery cookie设置值为布尔值true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此 jquery.cookie 插件,我需要将值设置为TRUE或NULL / FALSE。

I am using this jquery.cookie plugin and I need to set value to TRUE or NULL/FALSE.

我想这样做: $。cookie('ff',true,{expires:30,path:'/'} ;

I am trying to do it like this: $.cookie('ff', true, { expires: 30, path: '/' }); but it sets the value to string and not boolean.

Cookie只是字符串值。由于 gdoron已评论,如果您要将该值视为

Cookies are only string-valued. As gdoron commented, if you want to treat the value as a boolean, you need to parse it back to a boolean when the cookie value is read back out.

由于您注释到您正在使用PHP读取Cookie值,请参阅将字符串解析为PHP中的布尔值

Since you commented that you are reading the cookie value with PHP, see Parsing a string into a boolean value in PHP.

这篇关于jquery cookie设置值为布尔值true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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