Resume a CloakBrowser workspace with an IPWO proxy
A browser job can connect through the right proxy and still start from scratch every morning. Its saved filters, preferences or session data belong to browser storage; an unchanged proxy address does not restore them. For a returning workspace, you need to keep both the intended network connection and the right browser profile.
This guide connects an IPWO Static Residential proxy to CloakBrowser, saves a harmless test preference, closes the browser and verifies that the preference survives the next launch. It then repeats the exercise with a second workspace to check that their saved values stay separate.
Quick answer: Use launch_persistent_context() with a dedicated folder for each workspace and pass that workspace’s proxy configuration on every launch. Close the context normally, reopen the same folder and check the data you expected to retain. A profile saves browser state; it does not reserve an IP or guarantee that a website keeps an account signed in.
The example was tested with real CloakBrowser, persistent profile files and a local authenticated proxy. IPWO setup steps follow its documentation and supplied material. No live IPWO network or real account login was used in the test.
Connect an IPWO Static Residential proxy
Start with an active IPWO proxy. IPWO’s proxy retrieval instructions distinguish the static product from dynamic extraction: sign in to the user center, open Static Residential Proxy, then Static Residential IP Management to find the assigned address, port, username and password.
Use the HTTP connection details supplied for that allocation. Copy all four fields exactly. Do not append the dynamic product’s country, session ID or duration parameters to static credentials. If the dashboard shows several protocols, use the host and port for HTTP rather than changing only a SOCKS5 URL’s prefix.
| Item | What it controls |
|---|---|
| IPWO host, port and credentials | The browser’s proxy connection |
| Workspace name | Which local profile folder to open |
| Test page origin | Which site’s cookies and localStorage are available |
| Expected preference | What this demonstration must recover |
Complete the browser and license setup in the CloakBrowser Quick Start, then install the Python package:
python -m pip install --upgrade cloakbrowser
Keep the script and its ipwo-workspaces folder in a private local directory. Use a new workspace for this exercise, not your everyday browser profile. The example reads proxy credentials at runtime; reopening a folder does not choose the correct proxy configuration for you.
Save and verify a small piece of browser state
Save the next two Python blocks, in order, as workspace_check.py. The example writes only cloakbrowser_demo_preference on a page you own or are authorized to test. It stores the same nonsecret value in localStorage and a cookie with a one-day lifetime. This is an observable persistence check, not a login script.
import argparse
import json
import re
import warnings
from getpass import GetPassWarning, getpass
from ipaddress import ip_address
from pathlib import Path
from urllib.parse import urlsplit
from cloakbrowser import launch_persistent_context
PROFILE_ROOT = Path(__file__).resolve().parent / 'ipwo-workspaces'
IP_CHECK_URL = 'https://api.ipify.org?format=json'
MARKER = 'cloakbrowser_demo_preference'
def check_workspace(name, mode, value, proxy, target_url):
if not re.fullmatch(r'[A-Za-z0-9_-]{1,32}', name):
raise ValueError('Use a simple workspace name')
if mode not in {'save', 'reopen'}:
raise ValueError('Unknown mode')
if not re.fullmatch(r'[A-Za-z0-9_-]{1,40}', value):
raise ValueError('Use a simple nonsecret demo value')
parsed = urlsplit(target_url)
if parsed.scheme not in {'http', 'https'} or not parsed.hostname:
raise ValueError('Use an HTTP or HTTPS test page')
profile = PROFILE_ROOT / name
if mode == 'reopen' and not profile.is_dir():
raise ValueError('Workspace does not exist yet')
profile.mkdir(parents=True, exist_ok=True)
context = launch_persistent_context(str(profile), proxy=proxy)
try:
page = context.new_page()
response = page.goto(IP_CHECK_URL, wait_until='domcontentloaded',
timeout=30000)
if response is None or response.status != 200:
raise ValueError('IP check failed')
data = json.loads(page.locator('body').inner_text())
exit_ip = str(ip_address(str(data['ip'])))
response = page.goto(target_url, wait_until='domcontentloaded',
timeout=30000)
if response is None or response.status != 200:
raise ValueError('Test page did not return HTTP 200')
if mode == 'save':
# Only this deliberately named test preference is written.
page.evaluate('''({key, value}) => {
localStorage.setItem(key, value);
document.cookie = key + '=' + value
+ '; Path=/; Max-Age=86400; SameSite=Lax';
}''', {'key': MARKER, 'value': value})
local_value = page.evaluate('(key) => localStorage.getItem(key)',
MARKER)
cookies = [c['value'] for c in context.cookies(target_url)
if c['name'] == MARKER]
if local_value != value or cookies != [value]:
raise ValueError('Stored preference does not match')
return {'workspace': name, 'mode': mode, 'exit_ip': exit_ip,
'cookie': cookies[0], 'local_storage': local_value,
'result': 'PASS'}
finally:
# Closing flushes the persistent profile and stops its browser.
context.close()
Add the command-line entry point
Append this block to the same file. Use the same test page URL for every command below. The IP check runs as browser navigation before opening your test page. Its printed result helps you inspect the route; the PASS result specifically means both stored preference values matched.
def main():
parser = argparse.ArgumentParser()
parser.add_argument('workspace')
parser.add_argument('mode', choices=['save', 'reopen'])
parser.add_argument('value')
args = parser.parse_args()
url = input('Your authorized test page URL: ').strip()
host = input('IPWO HTTP host (without scheme): ').strip()
port = int(input('IPWO HTTP port: '))
username = input('Proxy username: ').strip()
with warnings.catch_warnings():
warnings.simplefilter('error', GetPassWarning)
password = getpass('Proxy password: ')
if (not host or any(c in host for c in '/:@?# ')
or not 1 <= port <= 65535 or not username or not password):
raise ValueError('Check the HTTP proxy fields')
proxy = {'server': f'http://{host}:{port}',
'username': username, 'password': password}
report = check_workspace(args.workspace, args.mode, args.value,
proxy, url)
print(json.dumps(report, indent=2))
if __name__ == '__main__':
try:
main()
except ValueError as exc:
# The script's own checks: safe to show, and they say what to fix.
print('Check failed:', exc)
raise SystemExit(1) from None
except Exception as exc:
# Raw network errors can contain credentials or private URLs.
print('Check failed:', type(exc).__name__)
raise SystemExit(1) from None
First save a value in workspace A, then run the reopen command as a separate invocation:
python workspace_check.py A save blue
python workspace_check.py A reopen blue
For both commands, enter the same authorized test URL and the IPWO connection assigned to A. The second invocation must read the existing value; reopen does not write or repair it. Each command closes the browser before it finishes.
Then save a different preference in workspace B and revisit both workspaces:
python workspace_check.py B save orange
python workspace_check.py A reopen blue
python workspace_check.py B reopen orange
Use B’s assigned proxy configuration when opening B. This example runs sequentially. It does not require two concurrent browser sessions, and you must not open one profile folder in two browser processes at the same time.
Read the report and test a wrong choice
Each successful command prints the workspace, operation, observed exit IP, recovered cookie and localStorage value. Both values must equal the argument you supplied. The profile folder is anchored to the script’s directory, so changing the terminal’s working directory does not silently select another folder.
The script opens ipify’s JSON endpoint through the configured browser. Use that observation to inspect whether the route is the one you intended. It does not prove IP ownership, residential classification, long-term stability or the absence of other network paths. Do not interpret persistence PASS as a complete network audit.
Try a deliberately wrong expectation:
python workspace_check.py A reopen orange
It should fail because A retained blue. Do not run save orange merely to make the check pass: that would overwrite the demonstration value and hide the wrong expectation. A new workspace name also cannot pass a reopen check before it has been saved.
What we verified
The controlled test used Python 3.14.3, CloakBrowser 0.7.1 and Playwright 1.62.0 on Windows. An authenticated local HTTP proxy forwarded a synthetic IP-check response and a plain test page. Every persistent context created a real browser process and was closed before the next launch. Profile files lived in a dedicated temporary directory outside the article folder.
| Test | Observed result |
|---|---|
| Save A, close, reopen A | Cookie and localStorage both restored blue |
| Save B, close, reopen A | A still restored blue |
| Reopen B after A | B restored orange |
| Wrong expected value or absent workspace | Rejected |
| Same folder, different test-page origin | Rejected: the expected state was unavailable |
| Invalid workspace path or HTTP 403 target | Rejected |
All 12 checks passed, including separate full command-entry runs for save and reopen. The origin also received the restored cookie on reopened page requests, so the test checked actual browser storage and HTTP behavior, not just a Python variable carried between calls. The test proxy’s reported IP was a documentation-only placeholder, not an IPWO exit.
Keep a workspace without confusing it with its connection
Maintain a small mapping outside the script: workspace A belongs to task A, uses folder A and the intended IPWO allocation. Workspace B gets its own folder and configuration. Keep credentials in your private credential store, not in a shared spreadsheet or the profile’s display name.
The two lifetimes are different. IPWO controls the proxy allocation and its validity. The profile controls browser data. Renewing or changing a proxy does not automatically move cookies to another folder; reusing a folder does not renew the proxy or prevent a website from asking you to sign in again.
Use persistent and temporary contexts deliberately. A fresh context suits first-visit tests. A persistent context suits work that needs its own previous state. For details on the underlying behavior, see Playwright’s persistent-context reference. In CloakBrowser, closing the returned context closes its browser and allows the profile to be reused by a later process.
Why did my saved value disappear?
Check the workspace name, script/profile location and exact page origin first. https://example.com and http://example.com have different localStorage; a different host or port changes the origin too. The test cookie expires after one day. A real website may clear or replace its own storage. Do not diagnose a proxy failure just because a preference is absent.
Does this keep me logged in indefinitely?
No. The example stores a test preference, not an authentication session. Real logins depend on cookie expiry, server-side session state, account policy and other checks. Persistent storage can retain the data a site permits you to reuse; it cannot force the server to accept it.
Can two folders use the same IPWO connection?
Separate folders keep browser storage separate even if you deliberately use one network route. They do not create separate IPs. If a workflow requires a different assigned address for each workspace, obtain and verify the appropriate allocations separately; folder names do not change the proxy’s behavior.
What should I keep private?
Profile folders can contain real session cookies and browsing data once you use them beyond this demonstration. Do not publish them or place them in a shared source repository. Keep only sanitized test reports when sharing results. The example suppresses raw connection exceptions because they can contain credentials.
Connect IPWO to your CloakBrowser workspace, save one harmless preference and verify it after a complete browser restart. Once that works, adapt the same folder discipline to an authorized task that needs returning browser state. Start with the CloakBrowser Quick Start if the browser is not installed yet.
Disclosure: This article may contain referral links. CloakBrowser may earn a commission if you make a purchase through them.