Behat & Mink Cookie Management

Profile picture for user devraj
Submitted by devraj on

You can manipulate cookie of different browser using Behat & Mink.

Three function you can perform on browser cookies:

  • Get Cookie
  • Set Cookie
  • Delete Cookie

Note: Drivers like Sahi that use JavaScript to control the browser, you may be restricted to accessing or setting all cookies except HttpOnly cookies.

Below is the sample code snippet for using cookie function:

// get cookie:
echo $session->getCookie('cookie name');

// set cookie:
$session->setCookie('cookie name', 'value');

// delete cookie:
$session->setCookie('cookie name', null);