Learn R Programming

cookiemonster (version 0.1.0)

add_cookies: 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, session, domain = NULL, confirm = FALSE)

Value

No explicit return. Instead, this function stores the cookies using the store_cookies function.

Arguments

cookiefile

A character string indicating the path to the cookie file.

cookiestring

A character string representing the cookie in string format.

session

A live html session created with read_html_live (only version >= 1.0.4).

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.

See Also

store_cookies

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

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

Run the code above in your browser using DataLab