HTTP presets
On this page
Some sites need a specific User-Agent, a set of pre-set cookies (to skip a
cookie-consent banner), or HTTP Basic Auth (to enter a preproduction). The
library reads these presets from the environment and applies them before the
first navigation, then keeps them across page re-creations (e.g. what
goToPage does internally).
#User-Agent
Set the browser's User-Agent for the whole run:
1PRESTAFLOW_USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
This is useful to pass anti-bot protections (Cloudflare's Browser Integrity
Check, for example) that reject the default PrestaFlow User-Agent.
#Preset cookies
Pass a JSON array of cookie objects via PRESTAFLOW_COOKIES. The library
sets each cookie before the first navigation and waits for the browser to
acknowledge each one (so it is deterministic).
1PRESTAFLOW_COOKIES=[{"name":"___kbgdcc","value":"eyIx...","domain":"preprod.example.com"}]
Each object accepts the following keys (name and value are required):
| Key | Notes |
|---|---|
name |
Cookie name. |
value |
Cookie value. |
domain |
Domain the cookie applies to. |
path |
Defaults to /. |
secure |
Boolean. |
httpOnly |
Boolean. |
sameSite |
Strict, Lax, or None. |
expires |
Unix timestamp. |
url |
Alternative to domain. |
The typical use case is to neutralise a cookie-consent banner (Knowband RGPD,
Axeptio, etc.). The library also ships a small FrontOffice\Rgpd page that
knows how to dismiss the Knowband banner if pre-setting the cookie is not an
option — see the FAQ.
#HTTP Basic Auth
Set the credentials via env:
1PRESTAFLOW_BASIC_USER=staging2PRESTAFLOW_BASIC_PASS=staging-password
The Authorization header is installed at the connection level, so it
survives every createPage() (which is what FrontOffice\Page::goToPage() and
FrontOffice\Page::goToUrl() do internally). No further code change is needed;
every navigation carries the header.
If the site's Basic Auth is on a specific host, make sure PRESTAFLOW_FO_URL
points to the protected origin — the header is applied on the origin of the
initial navigation.