Last updated: August 27, 2026.
Read cookies through Request.Cookies and write them through Response.Cookies.
<%
Response.Cookies("preferences")("theme") = "dark"
Response.Cookies("preferences").Expires = DateAdd("d", 30, Now())
Dim theme
theme = Request.Cookies("preferences")("theme")
If theme <> "dark" And theme <> "light" Then theme = "light"
Response.Write Server.HTMLEncode(theme)
%>| Control | Purpose |
|---|---|
| Secure | HTTPS only. |
| HttpOnly | Blocks script access to authentication cookies. |
| SameSite | Reduces cross-site request risk. |
| Short lifetime | Limits exposure. |
Apply missing modern attributes through a tested header or server configuration strategy. Never store passwords in cookies.