cookie module
Parse Cookie: headers into maps, and build Set-Cookie header values with the right attributes.
import "cookie" as cookie;
var parsed = cookie.parse("theme=dark; lang=en; sid=abc123");
print(parsed.theme); // dark
var sc = cookie.build("sid", "abc123", {
path: "/", http_only: true, max_age: 3600, same_site: "Lax"
});
// sid=abc123; Path=/; HttpOnly; Max-Age=3600; SameSite=Lax
API
| Function | Description |
|---|---|
cookie.parse(header) → map | Parse a Cookie: header value into {name: value, …}. |
cookie.build(name, value, opts) → string | Build a Set-Cookie value. opts: {path, domain, max_age, expires, http_only, secure, same_site}. |
cookie.delete_(name, opts) → string | Build a cookie that expires immediately — use to log out / clear a cookie on the client. |