httr::GET
preserves cookies when making requests to the same website.
Example:
# Get login cookie
r1 <- GET("https://some.url/login", authenticate("foo", "bar"))
cookies(r1)
# returns a data frame of two cookies
# Make request that requires authentication cookie
# Only succeeds if r1 was made
r2 <- GET("https://some.url/data/?query&subset=1")
r2
Notice that when making r2
you dont have to pass any cookie information explicitely as they are stored somewhere automatically.
I would like to know how these stored cookies can be queried or deleted?
Use a new handle to request.
h1 <- handle('')
r1 <- GET("https://some.url/login", handle=h1, authenticate("foo", "bar"))
h2 <- handle('')
r2 <- GET("https://some.url/data/?query&subset=1", handle=h2)