Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › authentication

How to Screenshot a Page Behind a Login with Cookies in a Screenshot API

By Freedom251 Team · · 6 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To screenshot a page behind a login, the renderer must receive valid authentication state before it opens the protected page. With a screenshot API, that usually means sending the session cookie or supported authentication header; if the site requires an interactive browser login, use browser automation such as Playwright to sign in, preserve the authenticated state, and then capture the page. In either case, check the returned status and image: an image response can still show a login or error page.

Before you send cookies to a screenshot API

Only capture an account and page you are authorized to access. A URL alone does not grant access: the screenshot service needs valid authentication state for the target site. Find out how that site authenticates before choosing a method.

As an Amazon Associate I earn from qualifying purchases.

  • Cookies: A session cookie may be enough if the service can set it on the correct host and the site accepts it.
  • Headers or tokens: Some sites authenticate requests with custom headers or bearer tokens; use these only when the screenshot provider documents support for them.
  • HTTP Basic Authentication: This applies when the protected site uses HTTP basic auth, not as a substitute for a normal website login.
  • Browser-driven login: If sign-in requires form interaction, redirects, local storage, or other browser behavior, a browser automation flow may be necessary.

Provider syntax and behavior differ. Check its current documentation for cookie format, domain and path handling, redirect behavior, credential limits, and how credentials are transmitted. A vendor’s example is not proof that every authentication flow or protected site will work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a hosted screenshot API with cookies or headers

For a page that accepts a supplied session cookie or authentication header, the basic process is to obtain valid credentials, pass them using the provider’s documented option, request the protected URL, and verify the result. Screenshot API documents a cookies parameter in name=value; name2=value2 form, repeatable custom header values, HTTP Basic Authentication, and a response header for the final page status. Its documentation says a 401 or 403 indicates that the rendered image is a login or error page: Screenshot API documentation.

#1 Best Overall
Sale
KODAK PIXPRO FZ45 16MP Compact Digital Camera, 4X Optical Zoom, AA, Black | 1080p Full HD Video, 27mm Wide Angle Lens, 2.7 Inch LCD, Point and Shoot, Digicam, Travel and Family Photos
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 4x optical zoom with a 27mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • LCD Screen and Battery: 2.7in LCD screen with 2 AA alkaline batteries for convenient on-the-go use

ScreenshotOne describes cookie-based rendering for authenticated pages when the site permits custom authentication data and does not block automation, or when the user owns the site. That is a vendor-specific example, not a guarantee for other providers or authentication methods: ScreenshotOne authenticated-pages guide.

  1. Confirm access and identify the mechanism. Make sure you are allowed to capture the page, then determine whether it uses cookies, headers or tokens, HTTP Basic Authentication, or an interactive login.
  2. Choose a provider that supports that mechanism. Read its documentation for the exact parameter names and cookie scope rules. Where supported, limit credentials to the target host and send only what is needed.
  3. Make the capture request. Pass the protected URL and authentication data using the provider’s documented syntax. Do not put secrets into a public URL, shared example, or source repository.
  4. Check the response and the screenshot. Inspect the final-page status when available, then visually confirm that the intended account and page appeared. A successful API response does not prove that authentication succeeded.

When to use Playwright instead

Use browser automation when authentication depends on completing a login flow in a browser or on state that a hosted API cannot set or preserve. Playwright’s authentication guidance covers saving and reusing storage state, including cookies, local storage, IndexedDB, and passkey/WebAuthn state. Its standard storage-state flow does not persist session storage; the documentation gives a separate save-and-restore pattern for that case: Playwright authentication.

Rank #2
KODAK PIXPRO FZ55 16MP Compact Digital Camera, 5X Optical Zoom, Red | 1080p Full HD Video, 28mm Wide Angle Lens, 2.7 Inch LCD, Point and Shoot, Vlogging Camera, Li-Ion Battery
  • 16MP Sensor: Captures detailed photos with a CMOS sensor for everyday shooting
  • Optical Zoom: 5x optical zoom with a 28mm wide angle lens for flexible framing indoors or outdoors
  • Full HD Video: Records 1080p video for travel clips, family moments, or simple vlogging
  • Memory Support: Works with Class 10 SD, SDHC, or SDXC cards up to 512GB
  • Rechargeable Battery: Included LB-012 lithium-ion battery charges in the camera over USB with the supplied adapter in about 2 hours; charge it for at least 4 hours before first use to maximize battery life

Install Playwright for your project and its browser runtime, then save this as capture-authenticated.cjs. Set LOGIN_URL, TARGET_URL, and the selectors to match your site. The example completes a form-based login, waits for a selector that only appears after login, writes storage state, opens a fresh context with that state, and captures the protected page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const loginUrl = process.env.LOGIN_URL;
  const targetUrl = process.env.TARGET_URL;
  const username = process.env.LOGIN_USER;
  const password = process.env.LOGIN_PASSWORD;

  if (!loginUrl || !targetUrl || !username || !password) {
    throw new Error('Set LOGIN_URL, TARGET_URL, LOGIN_USER, and LOGIN_PASSWORD');
  }

  try {
    const loginContext = await browser.newContext();
    const loginPage = await loginContext.newPage();
    await loginPage.goto(loginUrl, { waitUntil: 'domcontentloaded' });
    await loginPage.locator('input[name="username"]').fill(username);
    await loginPage.locator('input[name="password"]').fill(password);
    await loginPage.locator('button[type="submit"]').click();

    // Replace this with a selector that is only visible after successful login.
    await loginPage.locator('[data-testid="account-home"]').waitFor({ state: 'visible' });
    await loginContext.storageState({ path: 'playwright/.auth/state.json' });
    await loginContext.close();

    const authenticatedContext = await browser.newContext({
      storageState: 'playwright/.auth/state.json'
    });
    const page = await authenticatedContext.newPage();
    await page.goto(targetUrl, { waitUntil: 'domcontentloaded' });

    // Replace this with a page-specific ready condition if the page loads data later.
    await page.locator('body').waitFor({ state: 'visible' });
    await page.screenshot({ path: 'protected-page.png', fullPage: true });
    await authenticatedContext.close();
  } finally {
    await browser.close();
  }
})();

Run it with credentials supplied through your environment rather than hard-coded in the file:

Rank #3
Sale
Teslong Articulating Borescope for Mechanic Automotive HVAC Wall Inspection
  • Easily Maneuver Your View: Tired of struggling with hard-to-reach areas during inspections? This two-way articulating borescope effortlessly navigates tight and complex spaces with its flexible and maneuverable probe. Enjoy crystal-clear visual feedback that saves you both time and money. Whether for automotive maintenance or household inspections, this tool transforms your inspection journey, making the process faster and easier than ever.
  • See Every Detail in Vivid Clarity: Experience the exceptional image quality of our 4.5-inch IPS LCD color screen, delivering sharp, high-resolution visuals. Whether you’re in bright sunlight or dim conditions, this display ensures you won’t miss a thing. Plus, with no app required, it's ready to go whenever you are!
  • Master the Most Challenging Inspections: Equipped with a 5FT semi-rigid gooseneck cable, this borescope provides the ideal combination of flexibility and stability, allowing you to navigate tight, intricate spaces with ease. The cable retains its shape as you guide it, giving you precise control for thorough inspections. Designed for versatility, it adapts effortlessly to various environments, ensuring no detail goes unnoticed.
  • Light Up the Darkest Corners: Equipped with built-in high-brightness LED lights on the camera probe, you’ll have the visibility you need even in the darkest environments. The adjustable illumination allows you to customize the brightness for every inspection, ensuring that no detail goes unnoticed in tight or confined spaces.
  • Ergonomics Meet Efficiency: This borescope is thoughtfully designed for maximum comfort and usability. The centrally located articulating joystick allows for effortless one-handed operation with either hand. The photo button is conveniently positioned on the back, making it easy to capture images or videos during inspections. Lightweight and compact, this borescope ensures prolonged use without fatigue, perfect for on-the-go inspections.
LOGIN_URL='https://example.com/login' 
TARGET_URL='https://example.com/account' 
LOGIN_USER='your-username' 
LOGIN_PASSWORD='your-password' 
node capture-authenticated.cjs

Replace the example URLs and selectors with the ones for your site. The login confirmation selector matters: without it, the script may save an unauthenticated state and capture a login page. Playwright’s Page API documents navigation and screenshot options: Playwright Page API.

Protect the saved state

The file created by storageState may contain cookies and headers that can impersonate the account. Treat it like a password: exclude it from version control, restrict access, and use appropriate secret handling. If it is exposed, revoke or rotate the affected credentials. Session storage is not covered by the standard saved state flow, so follow Playwright’s separate documented pattern if the site depends on it.

Rank #4
4K Digital Camera for Photography, 50MP Vlogging Camera for YouTube, Compact Cameras with 2.8" 180° Flip Screen, 16X Digital Zoom, Point and Shoot Camera with 32GB SD for Beginners, Travel, Family
  • 【4K UHD & 50MP High-Def Shooting with 180° Flip Screen】Capture stunning videos and stills in ultra HD with this digital camera’s 2.8″ flip screen for framing. Whether documenting family trips, everyday moments, or creating video content, it delivers clear images and smooth video.Ideal mini camera & vlog camera companion.
  • 【16X Digital Zoom & Precise Autofocus】Get closer with 16X digital zoom and sharp autofocus on this point and shoot digital cameras camcorder. Even if you shoot from a distance, you can still take clear and beautiful photos. Whether shooting landscapes or portraits, this cameras for photography delivers crisp clarity every time.
  • 【Portable & Multi-Functional Design】Our mini camera weighs just 0.6 lbs and serves as a video camera, camcorder, and action camera. Built-in flash, time-lapse, and slow-motion modes make it the ultimate kids camera on the go.Record the beautiful and happy life of children.
  • 【Versatile for YouTube & Beyond】This vlog camera doubles as a webcam and supports Data line transfer for seamless sharing. Connect to PC for live streaming and video chats on youtube, making it the perfect digital camera for content creators.Whether you're recording a vlog on the go, filming a makeup tutorial, or capturing fun moments with friends, this camera has you covered.
  • 【Complete Accessories & Service】The camera comes with a 1500mAh rechargeable battery, which can be used continuously for 4-5 hours. Accessories includes a lens cleaning cloth, Type-C cable, 32GB card, carrying case, and lanyard.. Enjoy an 18-month WARRANTY and responsive customer support. Your camara awaits—ready for every adventure!

Or skip the browser setup

ScreenshotNeo accepts cookies, custom headers, and authorization data for captures. For example, its documented API call can request a page with a cookie:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/account --data-urlencode 'cookies=session=YOUR_SESSION_COOKIE' -o shot.webp

See the ScreenshotNeo documentation for authentication and request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo free.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the result

The image shows a login screen

  • Confirm the session has not expired and that the cookie belongs to the correct host and path.
  • Check whether a redirect changed the host or dropped the expected authentication state.
  • Determine whether the page also needs local storage, session storage, or an interactive login flow. A cookie alone may not be sufficient.
  • For a hosted API, check the final-page status header if the provider supplies one. Screenshot API documents 401 or 403 as indicating a login or error page.
  • For Playwright, wait for a reliable post-login condition before saving state; then inspect the captured page rather than relying on the request completing.

The provider returns an error or a blocked page

Check that the provider supports the site’s authentication method and that the credentials are current and correctly scoped. A site may block automated traffic or require a browser interaction the API cannot perform. Use a browser-driven flow when needed; do not assume that changing cookie syntax will overcome a site’s access controls.

Best Value
Sale
Fazoxo 2K Security Camera Wireless Outdoor, WiFi Cameras for Home Security
  • Solar-Powered for Extended Battery Life: The wirless camera comes with a high-efficiency solar panel(wire length 59 inch), designed to provide a consistent supplemental power source under adequate sunlight. This significantly reduces the need for manual recharging and supports a more sustainable, low-maintenance surveillance experience. It's an ideal power solution for long-term,wire-free outdoor installation
  • 2K UHD Clarity with Night Vision & 3x Zoom: This camera delivers crisp, detailed video day and night. It features standard infrared night vision for clear black-and-white footage in the dark, and a built-in spotlight mode that activates full-color night vision for more vivid details. The 3x digital zoom lets you focus on key areas like faces or license plates. (Compatible with 2.4GHz Wi-Fi networks only)
  • Flexible Storage Options: Your event-triggered videos are securely backed up with cloud storage(3 day trial). For extended coverage, you can upgrade to premium cloud plans (subscription required) or insert a microSD card (up to 128GB, not included) for local recording of motion events
  • Smart AI Detection & Instant Alerts: Receive prompt phone notifications when motion is detected. The basic motion detection works without any subscription. Can be individually set to recognize humans, so that all moving objects except for humans will not trigger detection
  • Two-Way Audio & Real-Time Interaction: Built-in microphone and speaker let you communicate directly through the app. Greet visitors, deter unwanted guests, or check in on your family and pets from anywhere

The page is blank or incomplete

The page may still be loading data when the capture occurs, or the authentication flow may have failed before navigation reached the intended content. Wait for a meaningful page-specific selector or state rather than assuming that a navigation event means the page is ready, and inspect the image for the expected content.

Quick Recap

Choose the method by the authentication flow

Need Hosted screenshot API Playwright
Already have a valid cookie or supported header Convenient if the provider documents that input and its scope matches the site. Can reuse browser storage, but requires maintaining a browser workflow.
Interactive login or browser-specific state May not support the needed flow; check the provider and site behavior. Designed for browser interaction and reusable storage state.
Session storage is required Support depends on the provider and is not established by the cited API examples. Not persisted by standard storage-state flow; use Playwright’s separate save-and-restore pattern.
Need to verify whether the capture reached the protected page Check the final-page status when exposed and inspect the image. Wait for a post-login or target-page condition and inspect the image.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

authenticationcookiesPlaywrightScreenshot APIsweb automation

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.