What are allowed characters in cookies?

前端 未结 13 1340
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 03:36

What are the allowed characters in both cookie name and value? Are they same as URL or some common subset?

Reason I\'m asking is that I\'ve recently hit some strange

13条回答
  •  面向向阳花
    2020-11-22 04:18

    I ended up using

    cookie_value = encodeURIComponent(my_string);
    

    and

    my_string = decodeURIComponent(cookie_value);
    

    That seems to work for all kinds of characters. I had weird issues otherwise, even with characters that weren't semicolons or commas.

提交回复
热议问题