Skip to content

Commit

Permalink
[cookies] fixes #309
Browse files Browse the repository at this point in the history
The reason for this bug, is because we just changed the semantics of setHeader
to overwrite any existing identical header and the cookie behaviour was depending
on the addative behaviour
  • Loading branch information
haf committed Oct 13, 2015
1 parent abec24b commit b650ab3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions examples/Example/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ let app =
path "/session"
>>= statefulForSession // Session.State.CookieStateStore
>>= context (fun x ->
match x |> HttpContext.state with
| None -> Redirection.FOUND "/session" // restarted server without keeping the key; set key manually?
match HttpContext.state x with
| None ->
// restarted server without keeping the key; set key manually?
let msg = "Server Key, Cookie Serialiser reset, or Cookie Data Corrupt, "
+ "if you refresh the browser page, you'll have gotten a new cookie."
OK msg

| Some store ->
match store.get "counter" with
| Some y ->
Expand Down
2 changes: 1 addition & 1 deletion src/Suave/Cookie.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module Cookie =
let unsetCookie (cookieName : string) =
let startEpoch = DateTimeOffset(1970, 1, 1, 0, 0, 1, TimeSpan.Zero) |> Some
let stringValue = HttpCookie.toHeader { HttpCookie.mkKV cookieName "x" with expires = startEpoch }
Writers.setHeader "Set-Cookie" stringValue
Writers.addHeader "Set-Cookie" stringValue

let setPair (httpCookie : HttpCookie) (clientCookie : HttpCookie) : WebPart =
context (fun { runtime = { logger = logger } } ->
Expand Down

0 comments on commit b650ab3

Please sign in to comment.