Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cookies preserved by httr::GET?

Tags:

r

httr

httr::GET preserves cookies when making requests to the same website.

  1. Is it possible to query those preserved cookies?
  2. How can I flush those preserved cookies and make "pristine" requests again?

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?

like image 222
Michał Avatar asked Oct 11 '16 14:10

Michał


People also ask

Can you clear cookies for one site Chrome?

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.


1 Answers

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)
like image 68
Timespace7 Avatar answered Sep 26 '22 04:09

Timespace7