Minima.js API / @minimajs/cookie / cookies / set
Function: set()
ts
function set(
name,
value,
options?): void;Defined in: index.ts:149
Sets a cookie to be sent in the response. The cookie value is immediately available for reading within the same request.
Parameters
name
string
The cookie name
value
string
The cookie value
options?
SerializeOptions
Cookie serialization options (path, domain, maxAge, etc.)
Returns
void
Example
typescript
// Simple cookie
cookies.set("theme", "dark");
// Secure session cookie
cookies.set("sessionId", "abc123", {
httpOnly: true,
secure: true,
maxAge: 3600, // 1 hour in seconds
sameSite: "strict",
});
// Cookie with custom path
cookies.set("adminToken", "xyz789", {
path: "/admin",
httpOnly: true,
});See
Since
1.0.0