コード例 #1
0
 function copyTo(lmbWebServerCookiesCollection $dest)
 {
     foreach ($this->cookies as $cookie) {
         $new_cookie = clone $cookie;
         $dest->add($new_cookie);
     }
 }
コード例 #2
0
 function testCopyTo()
 {
     $collect = new lmbWebServerCookiesCollection();
     $cookies = array(new lmbWebServerCookie('sid=sid1; expires=date; path=/; domain=.test.ru; secure'), new lmbWebServerCookie('sid=sid2; expires=date; path=/sub; domain=.test.ru; secure'), new lmbWebServerCookie('sid2=sid2; expires=date; path=/; domain=.test.ru; secure'));
     foreach ($cookies as $cookie) {
         $collect->add($cookie);
     }
     $collect2 = new lmbWebServerCookiesCollection();
     $cookies2 = array(new lmbWebServerCookie('sid=sid2; expires=date; path=/; domain=.test.ru; secure'));
     foreach ($cookies2 as $cookie) {
         $collect2->add($cookie);
     }
     $collect->copyTo($collect2);
     $it = $collect2->getIterator();
     $it->rewind();
     $cookie = $it->current();
     $this->assertClone($cookies[0], $cookie);
     $this->assertEqual($cookie->name, 'sid');
     $this->assertEqual($cookie->value, 'sid1');
     $this->assertEqual($cookie->path, '/');
     $it->next();
     $cookie = $it->current();
     $this->assertClone($cookies[1], $cookie);
     $this->assertEqual($cookie->name, 'sid');
     $this->assertEqual($cookie->value, 'sid2');
     $this->assertEqual($cookie->path, '/sub');
     $it->next();
     $cookie = $it->current();
     $this->assertClone($cookies[2], $cookie);
     $this->assertEqual($cookie->name, 'sid2');
     $this->assertEqual($cookie->value, 'sid2');
     $this->assertEqual($cookie->path, '/');
 }
コード例 #3
0
 protected function readCookies()
 {
     $cookies = new lmbWebServerCookiesCollection();
     $n = 0;
     while (($value = $this->response_headers->get('set-cookie', $n++)) !== null) {
         $cookies->add(new lmbWebServerCookie($value));
     }
     return $cookies;
 }