racket/collects/web-server/default-web-root/htdocs/servlets/examples/cookie.ss
Jay McCarthy 0b816d2942 cookies
svn: r13397
2009-02-03 22:32:35 +00:00

25 lines
560 B
Scheme

#lang web-server/insta
(require net/url)
(define (start req)
(define cookies (request-cookies req))
(define id-cookie
(findf (lambda (c)
(string=? "id" (client-cookie-name c)))
cookies))
(if id-cookie
(hello (client-cookie-value id-cookie))
(redirect-to
(url->string (request-uri req))
see-other
#:headers
(list
(cookie->header (make-cookie "id" "joseph"))))))
(define (hello who)
`(html (head (title "Hello!"))
(body
(h1 "Hello "
,who))))