store_cookies: Store cookies in a jar

View source: R/set.r

store_cookiesR Documentation

Store cookies in a jar

Description

Store cookies in a jar

Usage

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

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.

Value

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

Examples

# 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")
}

cookiemonster documentation built on May 29, 2024, 8:12 a.m.