Skip to contents

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie for a more in-depth description of each parameter's purpose.

Usage

cookie(
  ...,
  max_age = NULL,
  domain = NULL,
  path = NULL,
  same_site = "Lax",
  secure = FALSE,
  http_only = FALSE,
  partitioned = FALSE,
  name = ...names(),
  value = ..1
)

Arguments

...

A single key-value pair.

max_age

The number of seconds until expiration. Omit to create a session cookie. Inf is mapped to 34560000L (400 days).

domain

Send with requests to this host.

path

Send with requests to this path.

same_site

'Strict', 'Lax', or 'None'. secure required for 'None'.

secure

Only send over HTTPS.

http_only

Disallow javascript access.

partitioned

Use partitioned storage. secure required.

name

Explicitly set the name (key) in the key-value pair.

value

Explicitly set the value in the key-value pair.

Value

A 'header' object that can be passed to response().

Examples


    library(webqueue)
    
    cookie(xyz = 123, max_age = 3600, http_only = TRUE)
#> Set-Cookie: xyz=123; Max-Age=3600; HttpOnly
    
    token <- 'randomstring123'
    cookie(token)
#> Set-Cookie: token=randomstring123
    
    response(cookie(token = 'randomstring123'))
#> HTTP/1.1 200 OK
#> Set-Cookie: token=randomstring123
#> 
#> OK