8 * String to unset the cookie.
9 * Any date "in the past" will work, so I chose my birthday, right down to
10 * the exact minute. :)
12 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
13 typedef unsigned char byte; /* Byte type used by cookie_to_stuff() */
16 * Pack all session info into one easy-to-digest cookie. Healthy and delicious!
18 void stuff_to_cookie(int unset_cookies)
24 hprintf("Set-cookie: webcit=%s; path=/\r\n", unset);
28 StrBufAppendPrintf(WCC->HBuf, "Set-cookie: webcit=");
29 snprintf(buf, sizeof(buf), "%d", WCC->wc_session);
30 StrBufHexescAppend(WCC->HBuf, NULL, buf);
31 StrBufHexescAppend(WCC->HBuf, NULL, "|");
32 StrBufHexescAppend(WCC->HBuf, WCC->wc_username, NULL);
33 StrBufHexescAppend(WCC->HBuf, NULL, "|");
34 StrBufHexescAppend(WCC->HBuf, WCC->wc_password, NULL);
35 StrBufHexescAppend(WCC->HBuf, NULL, "|");
36 StrBufHexescAppend(WCC->HBuf, WCC->CurRoom.name, NULL);
37 StrBufHexescAppend(WCC->HBuf, NULL, "|");
38 StrBufHexescAppend(WCC->HBuf, NULL, get_selected_language());
39 StrBufHexescAppend(WCC->HBuf, NULL, "|");
41 if (server_cookie != NULL) {
42 StrBufAppendPrintf(WCC->HBuf,
47 StrBufAppendBufPlain(WCC->HBuf,
48 HKEY("; path=/\r\n"), 0);
54 * Extract all that fun stuff out of the cookie.
56 void cookie_to_stuff(StrBuf *cookie,
63 if (session != NULL) {
64 *session = StrBufExtract_int(cookie, 0, '|');
67 StrBufExtract_token(user, cookie, 1, '|');
70 StrBufExtract_token(pass, cookie, 2, '|');
73 StrBufExtract_token(room, cookie, 3, '|');
75 if (language != NULL) {
76 StrBufExtract_token(language, cookie, 4, '|');