method
Cookie.from
name: string,
value: string,
Creates a cookie from a name, value, and optional attributes
Referenced types
interface CookieInit
class Cookie
A single HTTP cookie: its name, value, and attributes.
const cookie = new Bun.Cookie("name", "value");
console.log(cookie.toString()); // "name=value; Path=/; SameSite=Lax"Returns
trueif the cookie has expiredSerializes the cookie to a string
const cookie = Bun.Cookie.from("session", "abc123", { domain: "example.com", path: "/", secure: true, httpOnly: true }).serialize(); // "session=abc123; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Lax"Returns the cookie's name, value, and attributes as a plain object
Serializes the cookie to a string. Alias of Cookie.serialize.
- name: string,value: string,
Creates a cookie from a name, value, and optional attributes