Use Cookie Generator

Enter your data below to use the Cookie Generator

📌 Try these examples:
RESULT

Last updated

Cookie Generator Examples

The Cookie Generator creates properly formatted HTTP Set-Cookie headers and JavaScript document.cookie strings. Below are examples for common cookie configurations with security attributes explained.

Session Cookie (HttpOnly + Secure)

A secure session cookie that expires when the browser closes:

Set-Cookie: sessionId=abc123xyz; Path=/; Secure; HttpOnly; SameSite=Lax

JavaScript equivalent (note: HttpOnly cookies cannot be set via JS — use server-side only):

// Server-side (Node.js / Express)
res.cookie('sessionId', 'abc123xyz', {
  httpOnly: true,
  secure: true,
  sameSite: 'lax',
  path: '/'
});

Persistent Authentication Cookie

A "remember me" cookie that persists for 30 days:

Set-Cookie: authToken=eyJhbGciOiJIUzI1NiJ9...; 
  Max-Age=2592000; 
  Path=/; 
  Domain=example.com; 
  Secure; 
  HttpOnly; 
  SameSite=Strict

User Preference Cookie (Non-HttpOnly)

A preference cookie that JavaScript needs to read:

Set-Cookie: theme=dark; Max-Age=31536000; Path=/; SameSite=Lax

Setting via JavaScript:

// Set theme preference cookie (1 year)
document.cookie = "theme=dark; max-age=31536000; path=/; samesite=lax";

Reading via JavaScript:

function getCookie(name) {
  const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
  return match ? match[2] : null;
}

const theme = getCookie('theme'); // "dark"

Cross-Site Cookie (SameSite=None)

Required for cookies used in iframes or cross-origin requests (e.g., embedded widgets):

Set-Cookie: widgetSession=tok_xyz; 
  Max-Age=3600; 
  Path=/; 
  Secure; 
  SameSite=None

Note: SameSite=None requires the Secure attribute — it will be rejected without it.

Path-Restricted Cookie

Cookie only sent for requests to the /admin path:

Set-Cookie: adminToken=secret123; Path=/admin; Secure; HttpOnly; SameSite=Strict

Domain-Scoped Cookie (Subdomains)

Cookie shared across all subdomains of example.com:

Set-Cookie: ssoToken=abc; Domain=.example.com; Path=/; Secure; HttpOnly; SameSite=Lax

This cookie will be sent to app.example.com, api.example.com, and example.com.

Cookie with Expiry Date

Using Expires instead of Max-Age:

Set-Cookie: promoSeen=1; 
  Expires=Fri, 31 Dec 2025 23:59:59 GMT; 
  Path=/; 
  SameSite=Lax

Deleting a Cookie

Set Max-Age=0 or an expired date to delete a cookie:

Set-Cookie: sessionId=; Max-Age=0; Path=/; Secure; HttpOnly

Via JavaScript:

document.cookie = "theme=; max-age=0; path=/";

Security Attribute Summary

Common Use Cases

Use the generator to configure each attribute through a visual interface and get the correctly formatted Set-Cookie header or JavaScript string ready to use in your application.

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.

Yes! Cookie Generator is completely free to use with no registration required. All processing is done client-side in your browser.

Absolutely! All processing happens locally in your browser. Your data never leaves your device, ensuring complete privacy and security.