What is it

dev.mccue.microhttp.setcookie provides a utility for generating a Set-Cookie header for use in a microhttp Response.

Why use it

Whenever a web browser receives a response from a website, depending on user settings, it will look for any SetCookie headers in that response. Data conveyed in those headers will be sent back to the server with every subsequent request.

This is one of the easiest ways to have persistent state, like user sessions, on a website.

Getting Started

import org.microhttp.Header;

import dev.mccue.microhttp.setcookie.SameSite;
import dev.mccue.microhttp.setcookie.SetCookieHeader;

void main() {
    Header header = SetCookieHeader.of("name", "value");
    // Header[name=Set-Cookie, value=name=value]

    Header otherHeader = SetCookieHeader.builder("name2", "value2")
    // Header[name=Set-Cookie, value=name2=value2; SameSite=Strict; Secure]

<- Index