path <- tempfile()
httpbin <- request(example_url()) |>
req_cookie_preserve(path)
# Manually set two cookies
httpbin |>
req_template("/cookies/set/:name/:value", name = "chocolate", value = "chip") |>
req_perform() |>
resp_body_json()
httpbin |>
req_template("/cookies/set/:name/:value", name = "oatmeal", value = "raisin") |>
req_perform() |>
resp_body_json()
# The cookie path has a straightforward format
cat(readChar(path, nchars = 1e4))
Run the code above in your browser using DataLab