public function testCookieWithAttributes() { $attributes = array('httponly', 'path' => '/'); $cookie = new Requests_Cookie('requests-testcookie', 'testvalue', $attributes); $this->assertEquals('requests-testcookie=testvalue', $cookie->formatForHeader()); $this->assertEquals('requests-testcookie=testvalue; httponly; path=/', $cookie->formatForSetCookie()); }
<?php // First, include Requests include '../library/Requests.php'; // Next, make sure Requests can load internal classes Requests::register_autoloader(); // Say you need to fake a login cookie $c = new Requests_Cookie('login_uid', 'something'); // Now let's make a request! $request = Requests::get('http://httpbin.org/cookies', array('Cookie' => $c->formatForHeader())); // Check what we received var_dump($request);