Cookies
Use cookies to set up browser state or check values written by your application. Puth's core cookie helpers operate on raw values and work on pages, not iframe-scoped browsers.
Read and write cookies
Visit the target origin before reading its cookies. Pass an array of cookie definitions to $browser->setCookie(); include a URL or domain to identify where each cookie belongs.
$browser->visit('https://app.test');
$browser->setCookie([
['name' => 'preference', 'value' => 'dark', 'url' => 'https://app.test'],
]);
$cookie = $browser->getCookieByName('preference');$browser->getCookieByName() returns the cookie object when it exists. Inspect that object for its value, domain and path.
Check a cookie
Use Laravel's plain-cookie assertions for raw values set through $browser->setCookie():
$browser->assertHasPlainCookie('preference');
$browser->assertPlainCookieValue('preference', 'dark');Laravel's encrypted-cookie helpers are described separately in Laravel cookies.
The generated PHP API includes raw-cookie assertions. They currently share the standalone assertion-binding limitation; the calls below show their signatures:
$browser->_assertHasCookie('preference');
$browser->_assertCookieValue('preference', 'dark');These assertions do not encrypt or decrypt cookie values.
Delete a cookie
Remove a cookie for the current page:
$browser->deleteCookie('preference');$browser->assertPlainCookieMissing('preference');$browser->_assertCookieMissing('preference');If a name exists under several domains or paths, pass cookie definitions with the matching domain/path to $browser->deleteCookie() instead of a name alone.
