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?
Delete Site-Specific Cookies in Chrome Or, easier yet, copy and paste: chrome://settings/siteData into the address bar and hit Enter. While you can scroll through the multitude of stored cookies here, it has a simple search feature that allows you to find the specific offending site cookie and delete it.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With