summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demo/cookieSec.ur2
-rw-r--r--src/c/urweb.c15
2 files changed, 13 insertions, 4 deletions
diff --git a/demo/cookieSec.ur b/demo/cookieSec.ur
index 447d38ad..98615c78 100644
--- a/demo/cookieSec.ur
+++ b/demo/cookieSec.ur
@@ -25,7 +25,7 @@ fun main () =
</body></xml>
and set r =
- setCookie username r.User;
+ setCookie username {Value = r.User, Expires = None, Secure = False};
main ()
and imHere () =
diff --git a/src/c/urweb.c b/src/c/urweb.c
index cbe065c3..aaa1278f 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -2667,10 +2667,19 @@ uw_Basis_string uw_Basis_get_cookie(uw_context ctx, uw_Basis_string c) {
}
if (p = uw_Basis_requestHeader(ctx, "Cookie")) {
+ char *p2;
+
while (1) {
- if (!strncmp(p, c, len) && p[len] == '=')
- return p + 1 + len;
- else if (p = strchr(p, ';'))
+ if (!strncmp(p, c, len) && p[len] == '=') {
+ if (p2 = strchr(p, ';')) {
+ size_t n = p2 - (p + len);
+ char *r = uw_malloc(ctx, n);
+ memcpy(r, p + 1 + len, n-1);
+ r[n-1] = 0;
+ return r;
+ } else
+ return p + 1 + len;
+ } else if (p = strchr(p, ';'))
p += 2;
else
return NULL;