setCookie
Description
Adds a header to the response to request the update of the cookie with the given name on the client.
Use the deleteCookie directive to delete a cookie.
Example
- Scala
-
val route = setCookie(HttpCookie("userName", value = "paul")) { complete("The user was logged in") } // tests: Get("/") ~> route ~> check { responseAs[String] shouldEqual "The user was logged in" header[`Set-Cookie`] shouldEqual Some(`Set-Cookie`(HttpCookie("userName", value = "paul"))) }
- Java