set_cookie

set_cookie($cookie); - set (add) cookies for the current page

The function accepts parameters as input:

  • $cookie – string with cookies separated by"; "

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

    PHP example: browser->".basename(__FILE__)."
    "; //1 echo "1.Let's go to Google:"; echo $browser->navigate("http://www.google.com/", "")."

    "; //2 echo "2.Get the current cookie:"; echo $browser->get_cookie()."

    "; //3 echo "3.Clear the current google cookies."; $browser->clear_cookies("", true, true); sleep(2); //4 echo "

    4.Get the new current google cookies:"; echo $browser->get_cookie()."

    "; //five echo "5.Let's set(add) cookies to Google:"; $cookie = "__ utma = 123272373.426502259.12244752769.12244752769.12424752775.2: __ utmb = 173272373.4.10.1244752775; __utmz = 173272373.1244752783.2.3.utmccn =(organic) | utmcsmctr = google | utmccn =(organic) | utmcsmctr adogle | utmse372.__utmv = 173272373.ExistingPublisher; PREF = ID = 1ab1131528cb1f1a: TM = 1244752750: LM = 1244752750: S = z8a6mTRmDHVImKOg; TZ = -180; GMAIL_RTT = 62; SID = DQAAAG4AAACVKgLK1udE8zJUkHfj7lB1exGg0rTbtWPXOIWORMueVZoT77XyJNTUltfGPonIuKt7PTVUs5qF-UvkhHR5cXcsIynN04AL3f7YMObLoOP5wkyGK9n7zHlw89Px0s8foYkobyH8Z9wzAZ2-FpZ7s9I3 "; echo $browser->set_cookie($cookie)."

    "; //6 echo "6.Get the current google cookies:"; echo $browser->get_cookie()."

    "; //end echo "

    "; //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("
    browser.xxxxxxxxx
    ") # 1 echo("1.Let's go to google:") echo(browser.navigate("http://www.google.com/", ""), "

    ") # 2 echo("2.Get the current cookie:") echo(browser.get_cookie(), "

    ") # 3 echo("3.Clear current google cookies.") browser.clear_cookies("google.com", true, true) # 4 echo("

    4.Get the current google cookies: empty") echo(browser.get_cookie(), "

    ") # five echo("5.Set(Add) cookies to Google:") cookie = "__ utma = 123272373.426502259.12244752769.12244752769.12424752775.2: __ utmb = 173272373.4.10.1244752775) __utmz = 173272373.1244752783.2.3.utmccn =(organic) | utmcscmctr = google | utmccn =(organic) | utmcscmctr = google | utm372.= 173272373.ExistingPublisher) PREF = ID = 1ab1131528cb1f1a: TM = 1244752750: LM = 1244752750: S = z8a6mTRmDHVImKOg) TZ = -180) GMAIL_RTT = 62) SID = DQAAAG4AAACVKgLK1udE8zJUkHfj7lB1exGg0rTbtWPXOIWORMueVZoT77XyJNTUltfGPonIuKt7PTVUs5qF-UvkhHR5cXcsIynN04AL3f7YMObLoOP5wkyGK9n7zHlw89Px0s8foYkobyH8Z9wzAZ2-FpZ7s9I3 " echo(browser.set_cookie(cookie), "

    ") # 6 echo("6.Get the current google cookie:") echo(browser.get_cookie(), "

    ") # end echo("

    ") # 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("
    browser.set_cookie
    "); //1 step echo("1.Let's go to Google:"); echo(browser.navigate("http://www.google.com/") + "
    "); //step 2 echo("2.Get the current cookies:"); echo(browser.get_cookie() + "
    "); //step 3 echo("3.Clear current google cookies."); echo(browser.clear_cookies("google.com", true, true) + "
    "); //step 4 echo("4.Get the current google cookies - empty:"); echo(browser.get_cookie() + "
    "); //step 5 echo("5.Let's set(Add) cookies to Google:"); string cookie = "__ utma = 123272373.426502259.12244752769.12244752769.12424752775.2: __ utmb = 173272373.4.10.1244752775; __utmz = 173272373.1244752783.2.3.utmccn =(organic) | utmcsmctr adogle.com | utmccn =(organic) | utmcsmctr adogle | utmccm72.__utmv = 173272373.ExistingPublisher; PREF = ID = 1ab1131528cb1f1a: TM = 1244752750: LM = 1244752750: S = z8a6mTRmDHVImKOg; TZ = -180; GMAIL_RTT = 62; SID = DQAAAG4AAACVKgLK1udE8zJUkHfj7lB1exGg0rTbtWPXOIWORMueVZoT77XyJNTUltfGPonIuKt7PTVUs5qF-UvkhHR5cXcsIynN04AL3f7YMObLoOP5wkyGK9n7zHlw89Px0s8foYkobyH8Z9wzAZ2-FpZ7s9I3 "; echo(browser.set_cookie(cookie) + "
    "); //step 6 echo("6.Get the current google cookies:"); echo(browser.get_cookie() + "
    "); //end echo("

    "); 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("
    browser.set_cookie
    "); //1 step echo("1.Let's go to Google:"); echo(browser.navigate("http://www.google.com/", "") + "

    "); //step 2 echo("2.Get the current cookies:"); echo(browser.get_cookie() + "

    "); //step 3 echo("3.Clear current google cookies."); echo(browser.clear_cookies("google.com", true, true) + " n n"); //step 4 echo("4.Get the current google cookie: empty"); echo(browser.get_cookie() + "

    "); //step 5 echo("5.Let's set(Add) cookies to Google:"); cookie = "__ utma = 123272373.426502259.12244752769.12244752769.12424752775.2: __ utmb = 173272373.4.10.1244752775; __utmz = 173272373.1244752783.2.3.utmccn =(organic) | utmcscmutr = google | utmccn = 173272373.ExistingPublisher; PREF = ID = 1ab1131528cb1f1a: TM = 1244752750: LM = 1244752750: S = z8a6mTRmDHVImKOg; TZ = -180; GMAIL_RTT = 62; SID = DQAAAG4AAACVKgLK1udE8zJUkHfj7lB1exGg0rTbtWPXOIWORMueVZoT77XyJNTUltfGPonIuKt7PTVUs5qF-UvkhHR5cXcsIynN04AL3f7YMObLoOP5wkyGK9n7zHlw89Px0s8foYkobyH8Z9wzAZ2-FpZ7s9I3 "; echo(browser.set_cookie(cookie) + "

    "); //step 6 echo("6.Get the current google cookies:"); echo(browser.get_cookie() + "

    "); //end echo("

    "); //Quit app.quit();