aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-08 19:35:27 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-08 19:35:27 +0000
commit39f06e27b72254c63d3ed9741efd3b528cc09e99 (patch)
tree979c19ce3ad7336418072b7107199531baf2e47e /doc
parent0bfe068c101ea5848950ed9fe4d4d32bd2a3f7f4 (diff)
downloadlibmicrohttpd-39f06e27b72254c63d3ed9741efd3b528cc09e99.tar.gz
libmicrohttpd-39f06e27b72254c63d3ed9741efd3b528cc09e99.zip
fix FIXME in tutorial
Diffstat (limited to 'doc')
-rw-r--r--doc/chapters/sessions.inc27
1 files changed, 22 insertions, 5 deletions
diff --git a/doc/chapters/sessions.inc b/doc/chapters/sessions.inc
index e4ee91d4..ee48e58e 100644
--- a/doc/chapters/sessions.inc
+++ b/doc/chapters/sessions.inc
@@ -16,10 +16,14 @@ Since MHD parses the HTTP cookie header for us, looking up an existing cookie
16is straightforward: 16is straightforward:
17 17
18@verbatim 18@verbatim
19FIXME. 19const char *value;
20
21value = MHD_lookup_connection_value (connection,
22 MHD_COOKIE_KIND,
23 "KEY");
20@end verbatim 24@end verbatim
21 25
22Here, FIXME is the name we chose for our session cookie. 26Here, "KEY" is the name we chose for our session cookie.
23 27
24 28
25@heading Setting the cookie header 29@heading Setting the cookie header
@@ -29,14 +33,27 @@ cookies. In order to generate a unique cookie, our example creates a random
2964-character text string to be used as the value of the cookie: 3364-character text string to be used as the value of the cookie:
30 34
31@verbatim 35@verbatim
32FIXME. 36char value[128];
37char raw_value[65];
38
39for (unsigned int i=0;i<sizeof (raw_value);i++)
40 raw_value = 'A' + (rand () % 26); /* bad PRNG! */
41raw_value[64] = '\0';
42snprintf (value, sizeof (value),
43 "%s=%s",
44 "KEY",
45 raw_value);
33@end verbatim 46@end verbatim
34 47
35Given this cookie value, we can then set the cookie header in our HTTP response 48Given this cookie value, we can then set the cookie header in our HTTP response
36as follows: 49as follows:
37 50
38@verbatim 51@verbatim
39FIXME. 52assert (MHD_YES ==
53 MHD_set_connection_value (connection,
54 MHD_HEADER_KIND,
55 MHD_HTTP_HEADER_SET_COOKIE,
56 value));
40@end verbatim 57@end verbatim
41 58
42 59