jquery cookie set value to boolean true

后端 未结 4 1206
太阳男子
太阳男子 2020-12-17 21:16

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

I am trying to do it like this: $.cookie(\'ff\', true, { expires: 30, path:

4条回答
  •  别那么骄傲
    2020-12-17 22:12

    Client side:

    $.cookie('ff', "true", { expires: 30, path: '/' });
    

    Server side:

    $cookie = $this->input->cookie() == "true";
    

    EDIT: Cookies are strings. Anything stored to cookies will need to be converted to strings. Hence you have to do the string to boolean conversion on the reading side of it. Above I have put an example for PHP (CodeIgniter).

提交回复
热议问题