在javascript cookie一次存储多个名/值对,不可以使用分号加空格(; )隔开
比如
document.cookie=”userId=828; userName=hulk”;
这样通过document.cookie获取只显示userId=828,而不显示后面的userName=hulk;
原因是在cookie 的名或值中不能使用分号(;)、逗号(,)、等号(=)以及空格,与网上的document.cookie=”userId=828; userName=hulk”;写法互相矛盾。
测试一下document.cookie=”userId=828; userName=hulk”;这样定义只对系统属性有效document.cookie=”userId=828; expires=....”;这样是允许的,但对于自定义属性是不能这样连写的