setCookie() public method

If a cookie has the same name and path it is replaced.
public setCookie ( string $name, string $value, string $host = false, string $path = '/', string $expiry = false )
$name string Cookie key.
$value string Value of cookie.
$host string Host upon which the cookie is valid.
$path string Cookie path if not host wide.
$expiry string Expiry date.
コード例 #1
0
ファイル: test_browser.php プロジェクト: erico-deh/ocPortal
 function testCookie()
 {
     $new_brswr = new SimpleBrowser();
     $new_brswr->setCookie('test', 'Nothing', false, '/', false);
     $cur_cookie = $new_brswr->getCookieValue(false, '/', 'test');
     $this->assertEqual('Nothing', $cur_cookie);
 }
コード例 #2
0
 /**
  * Fetch page from google and search for some keyword.
  */
 public function testFetchGoogleResults()
 {
     $browser = new SimpleBrowser();
     // inject debugging cookie, if we want to debug request - makes sense only if we do request to the same server with DBG module
     if (!empty($_COOKIE['DBGSESSID'])) {
         $browser->setCookie('DBGSESSID', $_COOKIE['DBGSESSID']);
     }
     $url = 'http://www.google.com/';
     $html = $browser->get($url);
     // store fetched page into temporary file and display quick download link
     TestUtils::snapshot($html, 'google-main-page');
     if ($this->assertTrue(false !== stripos($browser->getTitle(), 'google'), 'Failed loading page from ' . $url . '!')) {
         $keyword = 'simpletest';
         // load search results for "simpletest"
         $browser->setField('q', $keyword);
         $html = $browser->clickSubmitByName('btnG');
         if ($this->assertTrue(false !== strpos($browser->getTitle(), $keyword), 'Failed loading search results for ' . $keyword . '!')) {
             TestUtils::snapshot($html, 'google-search-results');
         }
     }
 }