set_scholar_cookie: set_scholar_cookie

View source: R/utils.R

set_scholar_cookieR Documentation

Description

set the Scholar session

Usage

set_scholar_cookie(cookie = NULL, file = NULL)

Arguments

cookie

a Cookie header value copied from a browser, such as "NID=...; GSP=...", or NULL to leave it unchanged

file

path to a cookie file exported from a browser, either in the Netscape format used by curl or as plain name=value text. Both a cookie and a file may be set; their entries are merged.

Details

Supply the session that lets Google Scholar treat this R session like the browser you are already signed in with. Some endpoints, author search among them, answer an anonymous request with a Google sign-in page while showing data in a browser; the difference is the cookie.

Google's own cookies are HttpOnly, so a browser will not reveal them to a script or a copy button: take them from the developer tools under Application, or with an extension that exports a cookie file. Published lifetimes are six months for NID and thirteen for _Secure-ENID and SOCS, counted from last use, and Google ends a session sooner when it looks automated, so expect to export it again. On a server or in CI, where there is no browser to copy from, set the SCHOLAR_COOKIE_FILE environment variable rather than passing the value here: a session is a credential, and an option or an argument lands in the command history. The session is sent only to a Google host, so a mirror set with set_scholar_mirror never receives it.

Value

NULL, invisibly; the values are stored as options

Author(s)

Guangchuang Yu

Examples

## Not run: 
  set_scholar_cookie(cookie = "NID=abc123; GSP=XQwERT")
  set_scholar_cookie(file = "~/scholar-cookies.txt")

## End(Not run)

scholar documentation built on Oct. 29, 2026, 9:08 a.m.