Pregunta

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!

¿Fue útil?

Solución

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 comes before the equal sign (=), and the value is what comes after it.

Otros consejos

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.com/", "/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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top