最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the difference between key and value in html cookies? - Stack Overflow

programmeradmin0浏览0评论

What is the difference between key and value in html cookies?

i saw that a cookie looks like this in html request:

  not like this:
    Cookie: name1=key1; name2=key2;

  but rather like this:
   Cookie: key1=value1; key2=value2; 

and if a want to make a unique personal id for each cookie, say "UUID",

should i write key="UUID"? or value="UUID"?

im sorry for the "silly" question but im really confused here...

thank you!

What is the difference between key and value in html cookies?

i saw that a cookie looks like this in html request:

  not like this:
    Cookie: name1=key1; name2=key2;

  but rather like this:
   Cookie: key1=value1; key2=value2; 

and if a want to make a unique personal id for each cookie, say "UUID",

should i write key="UUID"? or value="UUID"?

im sorry for the "silly" question but im really confused here...

thank you!

Share Improve this question edited Jan 4, 2012 at 20:39 Pete Wilson 8,7046 gold badges41 silver badges52 bronze badges asked Jan 4, 2012 at 20:32 Itzik984Itzik984 16.9k29 gold badges73 silver badges110 bronze badges 1
  • No question is silly. As long as it's correctly asked and formatted, it's accepted here on SO. – Madara's Ghost Commented Jan 4, 2012 at 20:34
Add a ment  | 

3 Answers 3

Reset to default 6

a key-value pair is a way of storing information in an easily readable manner. You designate each piece of data (value) with a key, and reference the data with that key. So in your case, the string "UUID" would be the key, and the actual unique ID would be the value.

uuid=4dh26532gf564836fgf597g36

In your example, name1 would actually be the key, where key1 would be the value.

In layman's terms, the key is what es before the equal sign (=), and the value is what es after it.

Keys are the names of the variables and values are, well the actual value of them. So to use your example, the key/value pair would be UUID=12345

Key value pair is a convenient way of storing structured data: the key designates the kind of information (e.g. be it a name, an identifier, a URL, a path, a hash of some data etc) and value designates a piece of data of the designated kind (e.g. "John", "1247", "http://example./", "/data/file1.txt", "4858200518452f9b374549459d644042" etc).

Thus a key is metainformation, i.e. information about information since it describes the kind of information that follows it.

Structured data is easier to analyse and use by programs since it is immediately obvious which part of the data has what meaning.

Note that in your example syntax is unconventional: it should be key=value, i.e. your keys are name1 and name2 and values are key1 and key2.

发布评论

评论列表(0)

  1. 暂无评论