add_cookies {cookiemonster}R Documentation

Add Cookies to the Browser

Description

This function allows you to add browser cookies to the cookie storage. It can work with either a cookie file or a direct cookie string (e.g., copied from a CURL call). But remember, just like in real life, you can't have your cookie and eat it too - pick only one!

Usage

add_cookies(cookiefile, cookiestring, domain = NULL, confirm = FALSE)

Arguments

cookiefile

A character string indicating the path to the cookie file.

cookiestring

A character string representing the cookie in string format.

domain

An optional parameter that specifies the host/domain. It's only used when cookiestring is provided.

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 explicit return. Instead, this function stores the cookies using the store_cookies function.

Note

You can't provide both a cookiefile and a cookiestring at the same time. That's like trying to dunk two cookies in a tiny cup of milk!

Your cookies are saved in an encrypted file. See encrypt_vec for more info.

See Also

store_cookies

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())

# Using a cookie file:
# 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.
add_cookies(cookiefile = system.file("extdata", "cookies.txt", package = "cookiemonster"))

# Using a cookie string:
add_cookies(cookiestring = "username=johndoe; password=secret", domain = "www.example.com")


[Package cookiemonster version 0.0.3 Index]