Cookies

Cookies are a useful way to keep user-specific information available, but you must use them securely because they are stored on the user's computer, and are vulnerable to spoofing or other malicious use.

Follow these guidelines:

Do not store any critical information in cookies. For example, do not store a user's password in a cookie, even temporarily.

Do not keep anything in a cookie that, if spoofed, can compromise your application. Instead, keep a reference in the cookie to a location on the server where the information is.

Set expiration dates on cookies to the shortest practical time you can. Avoid permanent cookies if possible.

Consider encrypting information in cookies.