Reputation: 1071
When receiving a request in a Play application, I can print the cookies like so:
println(request.cookies)
and the result is something like this:
Map(PLAY_SESSION -> Cookie(PLAY_SESSION,bd5712f8fb6a7a43935e20f98d6b147181dda9d5-inr=val1&uid=val2,None,/,None,false,true))
I just need the key bd5712f8fb6a7a43935e20f98d6b147181dda9d5
, is there a way to get it in Play or I have to parse the string?
Upvotes: 0
Views: 634
Reputation: 366
you can get cookie value like this :
val cookieValue = request.cookies.get(KEY) match {
case Some(cookie) => cookie.value
case None => ""
}
if you want to get only keys
val cookieNames = request.cookies.map{cookie =>
cookie.name
}
Upvotes: 1