본문 바로가기

Development/Web & Server

[Play Framework2] Setting and discarding cookies


Cookie를 사용하는 방법이다. (https://www.playframework.com/documentation/2.3.x/ScalaResults)


val result = Ok("Hello world").withCookies(
  Cookie("theme", "blue"))

Set

val result2 = result.discardingCookies(DiscardingCookie("theme"))

Discarding

val result3 = result.withCookies(Cookie("theme", "blue")).discardingCookies(DiscardingCookie("skin"))

Set & Discarding


def home(name:String) = Action {request=>

    

    val previousStr = request.cookies.get("test").get.value

    

    Ok("Hello").withCookies(Cookie("test", name))

  }


Get