コード例 #1
0
 public function testPersistsToFileFile()
 {
     $jar = new FileCookieJar($this->file);
     $jar->setCookie(new SetCookie(['Name' => 'foo', 'Value' => 'bar', 'Domain' => 'foo.com', 'Expires' => time() + 1000]));
     $jar->setCookie(new SetCookie(['Name' => 'baz', 'Value' => 'bar', 'Domain' => 'foo.com', 'Expires' => time() + 1000]));
     $jar->setCookie(new SetCookie(['Name' => 'boo', 'Value' => 'bar', 'Domain' => 'foo.com']));
     $this->assertEquals(3, count($jar));
     unset($jar);
     // Make sure it wrote to the file
     $contents = file_get_contents($this->file);
     $this->assertNotEmpty($contents);
     // Load the cookieJar from the file
     $jar = new FileCookieJar($this->file);
     // Weeds out temporary and session cookies
     $this->assertEquals(2, count($jar));
     unset($jar);
     unlink($this->file);
 }
コード例 #2
0
ファイル: Session.php プロジェクト: erpk/harvester
 public function save()
 {
     $this->cookieJar->save($this->savePath . '.cookies');
     file_put_contents($this->savePath . '.sess', serialize($this->data));
 }