jquery cookie设置值为布尔值true [英] jquery cookie set value to boolean 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屋!