Learn R Programming

cookiemonster (version 0.1.0)

store_cookies: Store cookies in a jar

Description

Store cookies in a jar

Usage

store_cookies(cookies, jar = default_jar(), confirm = FALSE)

Value

No return value, called to save (encrypted) cookies on disk.

Arguments

cookies

A data frame of cookies

jar

The directory to store the cookies in. Defaults to default_jar().

confirm

If TRUE, you confirm to write the cookie jar to disk (if it does not exist yet) without seeing the interactive menu.

Examples

Run this code
# to conform with CRAN policies, examples use a temporary location. Do not use
# the options like this, except you want your cookies gone when closing R.
options(cookie_dir = tempdir())

if (requireNamespace("curl", quietly = TRUE)) {
  # get cookies from a curl request
  library(curl)
  h <- new_handle()
  resp <- curl_fetch_memory("https://hb.cran.dev/cookies/set?new_cookies=moo", handle = h)
  cookies <- handle_cookies(h)

  # then store them for future use
  store_cookies(cookies)

  # then you can retrieve them and use in future calls
  get_cookies("hb.cran.dev")
}

Run the code above in your browser using DataLab