extract_cookie {cookies}R Documentation

Extract an individual cookie from a shiny request

Description

The shiny request object includes any cookies that are available to the app. This function extracts the value of a named cookie from that request.

Usage

extract_cookie(request, cookie_name, missing = NULL)

Arguments

request

A shiny request object.

cookie_name

The name of the cookie. Can contain any US-ASCII characters except for: the control character, space, a tab, or separator characters like ( ) < > @ , ; : \ " / [ ] ? = { }.

missing

The value to return if the requested cookie is not stored in the request. Defaults to NULL.

Value

The contents of that cookie.

Examples

req <- list(HTTP_COOKIE = "cookie1=expected_value; cookie2=1; cookie3=2")
extract_cookie(req, "cookie1")
extract_cookie(req, "cookie2")
extract_cookie(list(), "cookie1")
extract_cookie(NULL, "cookie1")

[Package cookies version 0.2.3 Index]