Skip to content

Instantly share code, notes, and snippets.

@manuelbernhardt
Created February 20, 2012 07:42

Revisions

  1. manuelbernhardt created this gist Feb 20, 2012.
    12 changes: 12 additions & 0 deletions gistfile1.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@

    val newSession = additionalSessionParams.foldLeft[Session](request.session) { _ + _ }
    val r: PlainResult = action(request).asInstanceOf[PlainResult]
    // workaround since withSession calls aren't composable it seems
    val innerSession = r.header.headers.get(SET_COOKIE).map(cookies => Session.decodeFromCookie(Cookies.decode(cookies).find(_.name == Session.COOKIE_NAME)))
    if(innerSession.isDefined) {
    // there really should be an API method for adding sessions
    val combined = innerSession.get.data.foldLeft(newSession) { _ + _ }
    r.withSession(combined)
    } else {
    r.withSession(newSession)
    }