It depends on the driver. With Chrome and Firefox you can set the behavior by setting the preferences with the driver.
Preferences with Chrome to allow/block the cookies:
// allow all cookies
"profile.default_content_setting_values.cookies": 1 // 1:allow, 2:block
"profile.block_third_party_cookies": false
// block third party cookies
"profile.default_content_setting_values.cookies": 1 // 1:allow, 2:block
"profile.block_third_party_cookies": true
// block all cookies
"profile.default_content_setting_values.cookies": 2 // 1:allow, 2:block
"profile.block_third_party_cookies": true
Preferences with Firefox to allow/block the cookies :
// allow all cookies
"network.cookie.cookieBehavior": 0
// block third party cookies
"network.cookie.cookieBehavior": 1
// block all cookies
"network.cookie.cookieBehavior": 2
To figure-out a preference, simply compare the preferences before and after changing the option manually in the target browser.
For Chrome the file is named Preferences. To get the path of this folder, navigate about:config with Chrome.
For Firefox, the file is named prefs.js. To get the path of this folder, navigate about:profiles with Firefox.