It's hard to tell without a reproducible example, but I think the httr code you want is this:
library(httr)
baseUrl <- "http://localhost:8080/myApp/"
POST(baseUrl, path = "j_spring_security_check",
body = list(j_username = "username", j_password = "password"),
multipart = FALSE,
verbose()
)
headers <- add_headers(
"Content-Type" = "application/json",
Accept = "application/json",
"Accept-Version" = "1.0"
)
GET(baseUrl, headers, verbose())
httr automatically sets up the handle to preserve cookies within a domain.