本文整理汇总了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());
}
示例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());
}
}
示例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());
}
示例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);
}
示例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);
}