User Tools

Site Tools


Sidebar

en:objects:browser:clear:clear_cookies

clear_cookies

clear_cookies($match_name,$clear_session=false,$clear_flash=true); - clear the specified cookies (information stored by sites on your computer)

the input Function accepts parameters:

  • $match_name – template for searching for sites whose cookies need to be cleared (part of the address), if an empty string is set - all
  • $clear_session – clear session cookies (true) or not clear (false) when executing the command. Session cookies - tracking the state of the user's access session;
  • $clear_flash – whether to clear (true) or not to clear (false) flash cookies

    After testing, the function returns the result of its work to the script :
  • true – completed successfully
  • false – failed to execute

    PHP example:

    <?php $xhe_host = "127.0.0.1:7013";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> browser->".basename(__FILE__)."</font> <hr>";
     
    //1
    echo "1.Let's go to Yandex, Google and then to a blank page:";
    echo $browser->navigate("ya.ru")."";
    echo $browser->navigate("google.com")."";
    echo $browser->navigate("about: blank")." n";
     
    echo "2 Display all Yandex cookies:";
    echo $browser->get_cookie_for_url("https://ya.ru/", "")." n";
     
    echo "3 Display all Google cookies:";
    echo $browser->get_cookie_for_url("https://google.com/", "")." n";
     
    //2
    echo "4.Clear Yandex cookies:";
    echo $browser->clear_cookies("https://ya.ru/")." n";
     
    echo "5.Display cookies from ya.ru:";
    echo $browser->get_cookie_for_url("https://ya.ru/", "")." n";
     
    echo "6.Display cookies from google.com:";
    echo $browser->get_cookie_for_url("https://google.com/", "")." n";
     
    //7
    echo "7.Clear everything:";
    echo $browser->clear_cookies("")." n";
     
    echo "8.Display cookies from google.com:";
    echo $browser->get_cookie_for_url("https://google.com/", "")." n";
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7013"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> browser.xxxxxxxxx </font> <hr>")
     
    #1
    echo("1.Clear cookies:")
    echo(browser.clear_cookies(""))
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7010";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> browser.clear_cookies </font> <hr>");
     
    //1 step
    echo("1.Let's go to the rambler's mail:");
    echo(browser.navigate("http://mail.rambler.ru") + "");
    echo(input.set_value_by_name("profile.login", "user@example.com") + "");
    echo(input.set_value_by_name("profile.password", "password") + "");
    echo(checkbox.check_by_attribute("id", "longSession", false, true) + "");
    echo(btn.get_by_number(0) .mouse_click() + "<br>"); sleep(4);
     
    //step 2
    echo("2.Let's go to a blank page:");
    echo(browser.navigate("about: blank") + "<br>");
     
    //step 3
    echo("3.Let's go back to the rambler(the login will be restored from cookies):");
    echo(browser.navigate("http://mail.rambler.ru") + "<br>"); sleep(5);
     
    //step 4
    echo("4.Let's go to a blank page:");
    echo(browser.navigate("about: blank") + "<br>");
     
    //step 5
    echo("5.Clean up temporary files:");
    echo(browser.clear_cookies("") + "<br>");
     
    //step 6
    echo("6.Let's go back to rambler(login is now reset):");
    echo(browser.navigate("http://mail.rambler.ru"));
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7010";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> browser.clear_cookies </font> <hr>");
     
    //1 step
    echo("1.Let's go to the rambler's mail:");
    echo(browser.navigate("http://mail.rambler.ru") + "");
    echo(input.set_value_by_name("login", "user@example.com") + "");
    echo(input.set_value_by_name("password", "password") + "");
    echo(checkbox.check_by_attribute("class", "form-checkbox__label", false, true) + "");
    echo(btn.get_by_number(0) .mouse_click() + "<br>"); browser.sleep(4);
     
    //step 2
    echo("2.Let's go to a blank page:");
    echo(browser.navigate("about: blank") + "<br>");
     
    //step 3
    echo("3.Let's go back to the rambler(the login will be restored from cookies):");
    echo(browser.navigate("http://mail.rambler.ru") + "<br>"); browser.sleep(5);
     
    //step 4
    echo("4.Let's go to a blank page:");
    echo(browser.navigate("about: blank") + "<br>");
     
    //step 5
    echo("5.Clean up temporary files:");
    echo(browser.clear_cookies("") + "<br>");
     
    //step 6
    echo("6.Let's go back to rambler(login is now reset):");
    echo(browser.navigate("http://mail.rambler.ru"));
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/browser/clear/clear_cookies.txt · Last modified: 2026/09/18 20:14 (external edit)