Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_http_cookie.h File Reference

Server-side cookies: read a Cookie header, build a Set-Cookie value. More...

#include "nilorea/n_str.h"
#include <stddef.h>
Include dependency graph for n_http_cookie.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  N_HTTP_SET_COOKIE
 what a Set-Cookie should carry More...

Macros

#define N_HTTP_COOKIE_SESSION   (-1LL)
 Max-Age value meaning "session cookie": neither Max-Age nor Expires is sent.

Enumerations

enum  N_HTTP_SAMESITE { N_HTTP_SAMESITE_UNSET = 0 , N_HTTP_SAMESITE_LAX = 1 , N_HTTP_SAMESITE_STRICT = 2 , N_HTTP_SAMESITE_NONE = 3 }
 SameSite attribute of a Set-Cookie. More...

Functions

size_t n_http_cookie_count (const char *header, size_t len, const char *name)
 count the pairs named name in a Cookie header value
const char * n_http_cookie_get (const char *header, size_t len, const char *name, size_t *value_len)
 find a cookie in a Cookie header value
int n_http_set_cookie_build (N_STR **out, const N_HTTP_SET_COOKIE *c)
 append a Set-Cookie header value (without "Set-Cookie: ")

Detailed Description

Server-side cookies: read a Cookie header, build a Set-Cookie value.

The server half of RFC 6265 (n_cookies.h is the client-side jar). Reading is zero-copy over the Cookie header value a request parser handed out; building refuses anything that would let a value break out of its attribute (CR, LF, ';', ',', spaces, quotes, controls) and enforces the cookie prefixes browsers enforce: a "__Host-" cookie must be Secure, have Path=/ and no Domain, a "__Secure-" one must be Secure, and SameSite=None must be Secure.

Author
Castagnier Mickael
Version
1.0
Date
2026

Definition in file n_http_cookie.h.