JavaScript Examples

JavaScript Menu

Home


 
 

  


Setting & Reading Cookies


You can set and read browser cookies from JavaScipt. This is a powerful technique for storing information that can be used at later time.

Cookie values are sent to the server with every request. This is why cookie value length are usually limited. The limitation differes by the browser, but you can count on 1Kb. You can also set the cokkie for a specific URL, then it will be sent ot the server only for that URL. Again, there is a limitation on a number of cookies the browser will save per web server (domain name). This is to prevent hackers for causing you an out of disk space condition.

On the server side cookies can be read from "HTTP_COOKIE" request parameter. The cookie can also be set by sending a "Set-Cookie: <value>" header in web server response.

Enter text: