Deleting cookies
In the previous section, we created a new cookie for the yahoo.com domain with the name 'username'
. We can also delete the same cookie simply by passing its name to the deleteCookie
function:
if( phantom.deleteCookie('username') ) { console.log('Cookie deleted.'); } else { console.log('Cookie not deleted or does not exist.'); }
If the desired cookie is not present, the function will not generate any error, but it will return a false
value. To clear all cookies, simply use the clearCookies
function.
phantom.clearCookies();