aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-02-12 15:55:13 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2026-02-12 16:10:37 +0100
commit1b2a52d214d92f543c9e0651f56c3292b23655a5 (patch)
treea892b5623895d3a323e982439201488281c08a34 /doc
parent424e46f5408776cd36d8258d3cbffa55acf56cc7 (diff)
downloadlibweb-1b2a52d214d92f543c9e0651f56c3292b23655a5.tar.gz
Add optional expiration date to http_cookie_create
So far, libweb had been arbitrarily appending a 1-year expiration date to all HTTP cookies. While good enough for some contexts, libweb should allow users to set up their own, if any, so this arbitary decision has been eventually removed.
Diffstat (limited to 'doc')
-rw-r--r--doc/man3/http_cookie_create.328
1 files changed, 14 insertions, 14 deletions
diff --git a/doc/man3/http_cookie_create.3 b/doc/man3/http_cookie_create.3
index 3ed78be..c439d91 100644
--- a/doc/man3/http_cookie_create.3
+++ b/doc/man3/http_cookie_create.3
@@ -1,4 +1,4 @@
-.TH HTTP_COOKIE_CREATE 3 2024-08-22 0.4.0 "libweb Library Reference"
+.TH HTTP_COOKIE_CREATE 3 2026-02-12 0.6.0 "libweb Library Reference"
.SH NAME
http_cookie_create \- creates a HTTP/1.1 cookie
@@ -8,7 +8,7 @@ http_cookie_create \- creates a HTTP/1.1 cookie
.nf
#include <libweb/http.h>
.P
-char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP);
+char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP, const struct tm *\fIexp\fP);
.fi
.SH DESCRIPTION
@@ -19,7 +19,13 @@ defined by
.I key
and
.IR value ,
-which are null-terminated strings.
+which are null-terminated strings, with an optional expiration date defined by
+.IR exp .
+
+If
+.I exp
+is a null pointer, no expiration date is set to the cookie, and therefore it
+effectively acts as a session cookie.
.SH RETURN VALUE
On success, a null-terminated string with the newly HTTP/1.1 cookie is
@@ -34,11 +40,13 @@ A successful call to
with
.I ExampleValue
as
-.I key
-and
+.IR key ,
.I ExampleValue
as
.I value
+and
+.I exp
+pointing to a given calendar time
might return a null-terminated string such as the one below:
.LP
@@ -48,19 +56,11 @@ ExampleHeader=ExampleValue; HttpOnly; Expires Wed, 07 Sep 2023 00:00:00 GMT
.EE
.in
-.SH FUTURE DIRECTIONS
-
-.I libweb
-sets a 1-year expiration date for HTTP cookies due to arbitrary design
-limitations. Future versions of this library shall allow a custom
-expiration date as an additional parameter to
-.IR http_cookie_create (3).
-
.SH SEE ALSO
.BR libweb_http (7).
.SH COPYRIGHT
-Copyright (C) 2023-2024 libweb contributors
+Copyright (C) 2023-2026 libweb contributors
.P
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by