aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorgoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-18 21:44:02 +0000
committergoodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2000-09-18 21:44:02 +0000
commit713755db4ba19ad39ef8593f8592a45cf3a53609 (patch)
tree0f8a60378a0e4395656387e193d0ab25651d7440 /doc
parent3969eb0efd59f2942493ed273e82ba63bfe5cc3a (diff)
Cookies.
These can be used to track the state of a users session, e.g. refresh data, watched vars, preferences, ... Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@46 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'doc')
-rw-r--r--doc/Cookies.txt80
1 files changed, 80 insertions, 0 deletions
diff --git a/doc/Cookies.txt b/doc/Cookies.txt
new file mode 100644
index 0000000..cd9a371
--- /dev/null
+++ b/doc/Cookies.txt
@@ -0,0 +1,80 @@
+ /*@@
+ @file Cookies.txt
+ @date Mon Sep 18 23:17:20 2000
+ @author Tom Goodale
+ @desc
+ Description of the Cookie interface.
+ @enddesc
+ @version $Header$
+ @@*/
+
+There is an interface for setting and querying cookies, which is
+accessed by including http_Cookies.h. This provides three functions
+
+int HTTP_CookieSend(httpRequest *request,
+ const char *name,
+ const char *value,
+ const char *path,
+ const char *domain,
+ const char *expires,
+ int secure);
+
+which will send a cookie with the appropriate name and value. All
+other fields may be set to NULL, or 0 as appropriate.
+
+int HTTP_CookieCancel(httpRequest *request,
+ const char *name,
+ const char *path);
+
+which cancels a cookie by setting its value to "" and setting the
+expiry date to the past.
+
+These two functions produce header lines, so should go between the
+HTTP response (e.g. HTTP/1.0 200 OK), and the "\r\n\r\n" seperating
+the header from the body.
+
+To get the value of a cookie, call
+
+char *HTTP_CookieGet(httpRequest *request,
+ const char *name);
+
+Note that the returned string must be freed afterwards.
+
+Currently no encoding is done on the value field; this will be added
+later. As a result things could go seriously wrong if you include a
+';' or 'name=', where 'name' is a cookie name, in the value field.
+
+
+Example:
+--------
+
+ /* Status message */
+ strcpy(message,"HTTP/1.0 200 OK\r\n");
+
+ HTTP_Write(request, message, strlen(message));
+
+ /* Cookie */
+ HTTP_CookieSend(request, "user", "niceuser", NULL,NULL,NULL,0);
+
+ strcpy(message,"Content-Type: text/html\r\n\r\n");
+
+ HTTP_Write(request, message, strlen(message));
+
+ /* Start of body */
+ strcpy(message, "<HTML><HEAD><TITLE>Cookie Test</TITLE></HEAD>\n");
+
+ strcat(message, "<BODY><center><h1>Cookie Test</h1></center>");
+
+ HTTP_Write(request, message, strlen(message));
+
+ strcpy(message, "<center>");
+ HTTP_Write(request, message, strlen(message));
+
+ value2 = HTTP_CookieGet(request,"user");
+
+ sprintf(message, "<p>Cookie is '%s'</p>\n", value2);
+
+ free(value2);
+
+...
+