get_cookies | R Documentation |
Imagine you're reaching into a magical jar overflowing with those scrumptious digital delights from websites you've visited. The flavour? Up to you! Just select your desired output format.
get_cookies(
domain,
key = "",
jar = default_jar(),
as = c("data.frame", "string", "vector"),
fixed = FALSE
)
domain |
A character string of the domain to retrieve cookies for.
Accepts regular expression depending on the value of |
key |
An optional filter to retrieve only certain cookies by matching
certain keys/names. Accepts regular expression depending on the value of
|
jar |
A character string of the path to the cookie jar (the default is
to use |
as |
A character string of the type of output to return. |
fixed |
If |
The function returns cookies in one of three formats:
data.frame: is how cookies are stored internally and can be used for manual inspection.
string: is used by curl
and httr2
.
vector: is used by httr
.
See vignette("cookies", "cookiemonster")
for how to use cookies with
these packages.
Depending on the value of as
, returns either a data frame, a
character string, or a named vector.
Your cookies are saved in an encrypted file. See encrypt_vec for more info.
add_cookies
# to conform with CRAN policies, examples use a temporary location. Do not use the options like this
options(cookie_dir = tempdir())
# put some cookies in the jar
add_cookies(cookiestring = "chococookie=delicious", domain = "example.com")
# Reach into your cookie jar and enjoy!
get_cookies("example.com")
# put different cookies into the jar (overwrites previous)
add_cookies(cookiestring = "oatmeal=delicious; peanutbutter=delicious", domain = "example.com")
add_cookies(cookiestring = "snickerdoodle=delicious", domain = "another.example.com")
# only get cookies for example.com, not another.example.com
get_cookies("^example.com")
# only get some cookies from example.com
get_cookies(domain = "^example.com", key = "peanut")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.