1234567891011121314151617181920212223 | #!/bin/sh
if [ -n "$COOKIE_foo" ]; then
body="Your existing cookie is '$COOKIE_foo'"
cat <<-EOF
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: ${#body}
$body
EOF
else
cookie="cookie$(date '+%s')"
body="Your brand new cookie is '$cookie'. It will last for 10 seconds."
cat <<-EOF
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: ${#body}
Set-Cookie: foo=$cookie; HttpOnly; Max-Age=10
$body
EOF
fi
# vim: ts=2:noexpandtab
|