How to delete Cookie in phantomjs?

Rajendra Negi
Rajendra Negi

Posted On: Jan 11, 2021

 

You can use the following code to delete Cookie in Phantomjs:

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();

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Phantomjs Interview Questions

    What is Phantomjs?

    PhantomJS is known as a web browser without a graphical user interface. PhantomJS is a headless WebKit and web browser scriptable with a JavaScript API. Its native support for various web standards su...

    Phantomjs Interview Questions

    Enlist some difference between puppeteer and phantomjs?

    PhantomJS is a headless WebKit scriptable with JavaScript which is used for web-related development workflow. Whereas Puppeteer is detailed as "Headless Chrome Node API". Basically, it is a Node libra...

    Phantomjs Interview Questions

    List major features of Phantomjs?

    The major features of Phantomjs are listed below:Page Automation Screen Capture Headless Testing Network Monitoring Ability to monitor the network connection ...