A cookie is a name/value pair that is stored in a browser.
On the server, a web application creates a cookie and sends it to the browser. On the client, the browser saves the cookie and sends it back to the server every time it accesses a page from that server.
By default, cookies only last until the user closes his or her web browser. However, cookies can be set to persist in the user’s browser until a specified expiration date.
Some users disable cookies in their browsers. As a result, you can’t always count on all users having their cookies enabled.
Browsers generally accept only 20 cookies from each site and 300 cookies total. In addition, they can limit each cookie to 4 kilobytes.
A cookie can be associated with one or more subdomain names.
Typical uses for cookies
To allow users to skip login and registration forms that gather data like username, password, address, or credit card data.
To customize pages that display information like weather reports, sports scores, and stock quotations.
To focus advertising like banner ads that target the user’s interests.
Description
A common misconception is that cookies are harmful. Since cookies consist only of plain text, they cannot directly modify a user’s computer, create pop-up ads, generate spam, or steal files.