aboutsummaryrefslogtreecommitdiff
path: root/doc/man3/http_cookie_create.3
blob: c439d91d50b7cf0fccca256d69e58b4e14cebad2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
.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

.SH SYNOPSIS
.LP
.nf
#include <libweb/http.h>
.P
char *http_cookie_create(const char *\fIkey\fP, const char *\fIvalue\fP, const struct tm *\fIexp\fP);
.fi

.SH DESCRIPTION
The
.IR http_cookie_create ()
function allocates a null-terminated string with a HTTP/1.1 cookie
defined by
.I key
and
.IR value ,
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
returned. Otherwise, a null pointer is returned.

.SH ERRORS
No errors are defined.

.SH EXAMPLE
A successful call to
.IR http_cookie_create (3)
with
.I ExampleValue
as
.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
.in +4n
.EX
ExampleHeader=ExampleValue; HttpOnly; Expires Wed, 07 Sep 2023 00:00:00 GMT
.EE
.in

.SH SEE ALSO
.BR libweb_http (7).

.SH COPYRIGHT
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.