iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Short answer: webshot::webshot() has no documented cookies argument. In webshot 0.5.5, the supported hook is eval: JavaScript that runs in the page after it opens and after delay, immediately before the screenshot is prepared. That can interact with a consent dialog or page state, but it is not a documented browser cookie jar and cannot be assumed to create an authenticated session on every site.
If you need a repeatable login or pre-navigation cookie state, test the exact target site’s supported session flow with a browser tool that documents cookie injection. If you only need a clean image or PDF from a URL, you can avoid the R browser setup with ScreenshotNeo; its API accepts custom cookies and removes common consent banners, popups and chat widgets before capture.
Does webshot support a cookies argument?
No. The webshot 0.5.5 reference manual does not list cookies (or a cookie-jar parameter) among the arguments to webshot(). Adding cookies = ... to a call therefore is not a documented solution and may produce an unused-argument error.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsThe documented extension point is eval. The package evaluates the supplied JavaScript after opening the page and waiting for delay, but before it calculates the clipping region and captures the image. The manual demonstrates using a Casper callback to interact with page elements. This timing is useful for page-side actions, not proof that arbitrary browser cookies can be injected before navigation.
Use the documented eval hook for page-side state
For a consent banner whose button is present in the page, you can ask PhantomJS to click it after the page loads. The following is intentionally schematic: replace the selector and action with code that the target site actually supports.
library(webshot)
webshot::webshot(
url = "https://example.com",
file = "capture.png",
delay = 2,
eval = "
// Page-side JavaScript. Adapt to the target site's DOM.
var button = document.querySelector('[data-accept-cookies]');
if (button) button.click();
"
)
Set delay long enough for the page and its consent component to appear. A click may cause a site to set a cookie through its own JavaScript, but the package documentation does not guarantee that this works for a particular consent-management platform, cross-origin frame, secure authentication flow or server-side redirect.
#1 Best Overall
Why this is not cookie injection
- The script runs in the loaded document, after navigation has already occurred.
document.cookieis restricted by the site’s domain, path,Secure,SameSiteandHttpOnlyrules.- HttpOnly session cookies cannot be written by page JavaScript.
- A login that requires redirects, anti-bot checks, multi-factor authentication or a browser profile may not be reproducible with
eval.
Use this approach only when you can verify the resulting page and cookie behavior against your own site. Do not put passwords or long-lived session values in scripts that may be committed to source control.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Install and run the original package
The original webshot package uses the external PhantomJS program. The package introduction recommends installing it with webshot::install_phantomjs(), or installing PhantomJS manually and making the executable available on your system PATH.
- Install the R package:
install.packages("webshot") - Install the runtime from R when appropriate:
webshot::install_phantomjs() - Verify a basic capture before adding cookie logic:
webshot::webshot("https://example.com", "test.png") - Add
delayand the documentedevalhook only after the basic capture succeeds.
The install_phantomjs(version = "2.1.1", ...) helper was designed primarily to simplify Windows installation. The documented locations vary by platform: Windows uses APPDATA, macOS uses ~/Library/Application Support, and Linux and other systems use locations such as ~/bin, with the package’s own PhantomJS directory as a fallback. A manually installed executable must be discoverable on PATH.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Should you use webshot2 instead?
webshot2 is the maintained-style replacement described by its official repository. It uses headless Chrome through the Chromote package rather than PhantomJS, so Chrome or another Chromium-based browser must be installed. Its documented webshot() signature also does not include a cookies argument.
| Capability | webshot |
webshot2 |
|---|---|---|
| Browser backend | PhantomJS | Headless Chrome via Chromote |
| Runtime requirement | install_phantomjs() or PhantomJS on PATH |
Chrome or a Chromium-based browser |
| Documented cookie parameter | None; eval provides page-side JavaScript |
None in the documented function parameters |
| Best use of the package | Existing PhantomJS workflows and simple page interactions | Projects that need a newer Chrome-based rendering engine |
Migration can improve browser compatibility, but it should not be presented as a guaranteed cookie solution. Read the documentation for the versions installed in your environment and test your target site.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallReliable workflow for an authenticated capture
1. Separate consent from authentication
Determine whether you need to dismiss a public cookie banner or restore a logged-in session. A public banner may be handled by a page-side click. An authenticated page normally depends on server-set, often HttpOnly, cookies and a supported login flow.
2. Reproduce the supported session flow
Check whether the site provides a test account, API token, signed URL or other documented method. Do not assume that copying a browser’s cookie text into JavaScript is safe or sufficient. Validate redirects, permissions, expiry and logout behavior.
Rank #3
3. Capture a diagnostic page first
webshot::webshot(
"https://your-site.example/account",
"account-debug.png",
delay = 3,
vwidth = 1440,
vheight = 900
)
Inspect the image for a login redirect, consent overlay, bot challenge, blank content or a partially rendered application. These outcomes tell you whether the problem is session state, timing or rendering.
4. Keep secrets out of logs
Use environment variables or a secret manager for credentials and session values. Restrict output files, remove diagnostic images containing personal data and rotate any token that was accidentally committed.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshooting common failures
“unused argument (cookies = …)”
Cause: the documented webshot() API has no cookies parameter. Fix: remove it and use the documented eval hook only for page-side actions, or choose a browser automation API that explicitly documents cookie injection.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
“PhantomJS not found” or an executable error
Cause: PhantomJS is not installed or is not on PATH. Fix: run webshot::install_phantomjs(), restart R, or install the executable manually and verify it is discoverable from the same account that runs your script.
The banner remains visible
Cause: the selector is wrong, the banner is inside an iframe, or it appears after your delay. Fix: inspect the live DOM, increase delay, wait for the component’s actual appearance, and check whether the frame is cross-origin. A cross-origin frame may not be scriptable from the page.
The click runs but the next request is still logged out
Cause: a page-side click did not establish the server session, or the flow requires HttpOnly cookies, redirects or additional challenges. Fix: use the site’s supported authentication mechanism and verify the exact browser/session API you select; eval alone is not a documented pre-navigation cookie store.
The screenshot is blank or incomplete
Cause: the page is still loading, JavaScript rendering is delayed, resources are blocked, or PhantomJS cannot render a modern feature. Fix: increase delay, capture a simpler diagnostic page, inspect network and console errors where available, and consider testing the same workflow with webshot2 and a Chromium runtime.
Best Value
Performance, repeatability and cost considerations
- Use the smallest viewport and image dimensions that meet your requirement; very large full-page captures consume more memory.
- Choose a deterministic delay based on the target’s rendering behavior, then verify the output rather than assuming the timer means “fully loaded.”
- Run captures in an isolated environment when handling private pages, and avoid sharing output files that contain account data.
- Pin and record your R package and browser versions. The APIs and rendering behavior can change, so recheck the installed-version documentation before relying on version-specific code.
- There is no documented numeric guarantee in the package manuals for cookie success, capture reliability or authentication compatibility. Your target site remains the authority.
Or skip the browser setup
For a URL-to-image or PDF workflow, ScreenshotNeo provides a single HTTP endpoint. It supports custom cookies, JavaScript and CSS, waits, device and viewport settings, full-page capture, element selection, PDF output and other capture controls. Before capture it accepts the cookie/consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off.
Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
R
install.packages("httr2")
library(httr2)
request("https://api.screenshotneo.com/v1/shot") |>
req_url_query(
access_key = Sys.getenv("SCREENSHOTNEO_API_KEY"),
url = "https://stripe.com"
) |>
req_perform() |>
resp_body_raw() |>
writeBin("shot.webp")
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));
See the ScreenshotNeo API documentation for cookie, wait, viewport, PDF, webhook, caching and bulk-capture parameters. Plans include 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000 shots, with every feature on every plan. Create a free ScreenshotNeo account to get started.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Can I set an HttpOnly cookie with webshot’s eval option?
No. Page JavaScript cannot write HttpOnly cookies, and webshot documents eval as a page-side script hook rather than a browser cookie-store API.
Will webshot2 automatically preserve my Chrome cookies?
Not based on its documented webshot() parameters. It uses Chrome through Chromote, but you must verify any separate session or cookie mechanism for the exact version and workflow you use.
Is PhantomJS installation enough to make authenticated screenshots work?
No. Installation only supplies the browser runtime. Authentication still depends on the target site’s supported login and session behavior.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →

