Play framework WS set cookie

How to set a cookie in a WS request?

val request = WS.url("http://testurl.com/test.pdf") 

Is it possible?

I am using Play version 2.1.1

+6
source share
2 answers
 WS.url(theurl).withHeaders("Cookie" -> "cookiename=cookieval; name2=val2") 
+12
source

You can also add the domain and path to the cookie in the same way

 WS.url("http://url.com").withHeaders("Cookie" -> "cookieName=value; domain=url.com; path=/") 
0
source

Source: https://habr.com/ru/post/951210/


All Articles