← All text tools

Set-Cookie Header Generator

Build a Set-Cookie header with Secure, HttpOnly, SameSite, Domain, Path and expiry options, get warnings about invalid combinations, and copy header, JavaScript, Node and PHP code.

  • Free
  • No sign-up
  • Works on any device

About Set-Cookie Header Generator

A Set-Cookie header sets a cookie from the server, and its attributes decide who can read it. This generator assembles the header from name, value, Domain, Path, Max-Age, Expires, Secure, HttpOnly, SameSite and Partitioned, and checks the rules browsers enforce: SameSite=None needs Secure, the __Host- prefix needs Secure, Path=/ and no Domain, and a value cannot hold spaces, commas or semicolons. It also prints code for browser JavaScript, Node.js and PHP, so a login cookie can be built correctly the first time.

How to use Set-Cookie Header Generator

  1. Type the cookie name and value, then set the lifetime with Max-Age in seconds or leave it empty for a session cookie.
  2. Choose SameSite and tick Secure, HttpOnly or Partitioned as needed, reading any warning that appears.
  3. Copy the header or the code snippet for your language and send it from your server.

Why use this tool?

Also known as

Frequently asked questions

Why does the page say SameSite=None needs Secure?

Browsers reject a SameSite=None cookie that is not marked Secure, so it would silently never be stored. Tick Secure and serve the site over HTTPS.

Can JavaScript set an HttpOnly cookie?

No. An HttpOnly cookie can only be set by the server in a Set-Cookie header, which is the point of the flag. The JavaScript snippet therefore leaves it out.

What happens if I set both Max-Age and Expires?

Browsers use Max-Age and ignore Expires. The tool warns you so you can keep just one.

Is Set-Cookie Header Generator free?

Yes. Set-Cookie Header Generator on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.

Can I put Set-Cookie Header Generator on my own website?

Yes. Use the Embed on your site button under the tool to copy a short piece of code and paste it into your page. It is free, needs no account, and the tool keeps working inside your page.

Related tools