cookie_jar.php 514 B

1234567891011121314151617181920
  1. <?php
  2. // First, include Requests
  3. include('../library/Requests.php');
  4. // Next, make sure Requests can load internal classes
  5. Requests::register_autoloader();
  6. // Say you need to fake a login cookie
  7. $c = new Requests_Cookie_Jar(['login_uid' => 'something']);
  8. // Now let's make a request!
  9. $request = Requests::get(
  10. 'http://httpbin.org/cookies', // Url
  11. [], // No need to set the headers the Jar does this for us
  12. ['cookies' => $c] // Pass in the Jar as an option
  13. );
  14. // Check what we received
  15. var_dump($request);