當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SimpleCookieJar::setCookie方法代碼示例

本文整理匯總了PHP中SimpleCookieJar::setCookie方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleCookieJar::setCookie方法的具體用法?PHP SimpleCookieJar::setCookie怎麽用?PHP SimpleCookieJar::setCookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleCookieJar的用法示例。


在下文中一共展示了SimpleCookieJar::setCookie方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCookieJarIsSentToRequest

 function testCookieJarIsSentToRequest()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'A');
     $request =& new MockSimpleHttpRequest();
     $request->setReturnReference('fetch', $this->_createStandardResponse());
     $request->expectOnce('readCookiesFromJar', array($jar, '*'));
     $agent =& $this->_createMockedRequestUserAgent($request);
     $agent->setCookie('a', 'A');
     $agent->fetchResponse(new SimpleUrl('http://this.com/this/path/page.html'), new SimpleGetEncoding());
 }
開發者ID:pvalencia,項目名稱:CoordinaChile,代碼行數:11,代碼來源:user_agent_test.php

示例2: writeCookiesToJar

 /**
  *    Writes new cookies to the cookie jar.
  *    @param SimpleCookieJar $jar   Jar to write to.
  *    @param SimpleUrl $url         Host and path to write under.
  *    @access public
  */
 function writeCookiesToJar(&$jar, $url)
 {
     foreach ($this->_cookies as $cookie) {
         $jar->setCookie($cookie->getName(), $cookie->getValue(), $url->getHost(), $cookie->getPath(), $cookie->getExpiry());
     }
 }
開發者ID:JackCanada,項目名稱:moodle-hacks,代碼行數:12,代碼來源:http.php

示例3: testCookieClearByLoweringDate

 function testCookieClearByLoweringDate()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'abc', false, '/', 'Wed, 25-Dec-02 04:24:21 GMT');
     $jar->setCookie('a', 'def', false, '/', 'Wed, 25-Dec-02 04:24:19 GMT');
     $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array('a=def'));
     $jar->restartSession('Wed, 25-Dec-02 04:24:20 GMT');
     $this->assertEqual($jar->selectAsPairs(new SimpleUrl('/')), array());
 }
開發者ID:ahiliation,項目名稱:beautifulwork,代碼行數:9,代碼來源:cookies_test.php

示例4: testMultipleCookieWriting

 function testMultipleCookieWriting()
 {
     $socket =& new MockSimpleSocket();
     $socket->expectArgumentsAt(0, 'write', array("Cookie: a=A;b=B\r\n"));
     $route =& new MockSimpleRoute();
     $route->setReturnReference('createConnection', $socket);
     $jar = new SimpleCookieJar();
     $jar->setCookie('a', 'A');
     $jar->setCookie('b', 'B');
     $request =& new SimpleHttpRequest($route, new SimpleGetEncoding());
     $request->readCookiesFromJar($jar, new SimpleUrl('/'));
     $request->fetch(15);
 }
開發者ID:pvalencia,項目名稱:CoordinaChile,代碼行數:13,代碼來源:http_test.php

示例5: testCookieClearByDate

 function testCookieClearByDate()
 {
     $jar = new SimpleCookieJar();
     $jar->setCookie(new SimpleCookie("a", "abc", "/", "Wed, 25-Dec-02 04:24:21 GMT"));
     $jar->setCookie(new SimpleCookie("a", "def", "/", "Wed, 25-Dec-02 04:24:19 GMT"));
     $cookies = $jar->getValidCookies(false, "/");
     $this->assertIdentical($cookies[0]->getValue(), "def");
     $jar->restartSession("Wed, 25-Dec-02 04:24:20 GMT");
     $this->assertEqual(count($jar->getValidCookies(false, "/")), 0);
 }
開發者ID:justinlyon,項目名稱:scc,代碼行數:10,代碼來源:user_agent_test.php


注:本文中的SimpleCookieJar::setCookie方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。