cookie的name和value

Constructs a cookie with a specified name and value.

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method

以上是官方对cookie的构造方法的说明。

cookie的name需要遵循规范RFC2109,只能包含字母或者数字,不能包含逗号、分号、空格及美元符号,并且名字确定后不能再更改。

cookie的value可以是服务端设置的任意值,该值可以通过setValue方法进行重新设置。

!但是value最好也只包含字母和数字,不要包含逗号、分号、空格等特殊字符!

猜你喜欢

转载自www.cnblogs.com/da-hao/p/13164644.html