~inc:header.inc~

# Cookies

Cookies are small text strings that are stored in the browser. These strings are set by the server, and returned as parameters for all future requests until the session ends. They can be used to store session state information, and are valid until the browser is closed.

Name: | ~cookiename~
Favorite: | not implemented

There are numerous uses for cookies. In this example, the user's name is stored as a cookie. All future page loads will show this name in the top left corner, as well as in the box above.

First Name: |
Favorite: |

Cookies are set by storing null-terminated name/value pairs in `curHTTP.data` and indicating how many cookies are to be set in `curHTTP.hasArgs`. They can be set in either `HTTPExecuteGet` or `HTTPExecutePost`.

Cookies are retrieved in the same manner as GET form arguments. They are stored in `curHTTP.data` and can be located using the `HTTPGetArg` functions. Since they are stored in the same array as GET arguments, the total length of cookies and variable arguments cannot exceed the 80 byte buffer limit.

Exercise: Set a second cookie named `fav` with the value of the `favorite` field and have it displayed in the gray box above.

~inc:footer.inc~