xref: /PHP-5.3/ext/curl/tests/curl_basic_011.phpt (revision d80adbcc)
1--TEST--
2Test curl_opt() function with COOKIE
3--CREDITS--
4TestFest 2009 - AFUP - Xavier Gorse <xgorse@elao.com>
5--SKIPIF--
6<?php if (!extension_loaded("curl") || false === getenv(b'PHP_CURL_HTTP_REMOTE_SERVER')) print "skip need PHP_CURL_HTTP_REMOTE_SERVER environment variable"; ?>
7--FILE--
8<?php
9/* Prototype  : bool curl_setopt(resource ch, int option, mixed value)
10 * Description: Set an option for a cURL transfer
11 * Source code: ext/curl/interface.c
12 * Alias to functions:
13 */
14
15  $host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
16
17  // start testing
18  echo '*** Testing curl with cookie ***' . "\n";
19
20  $url = "{$host}/get.php?test=cookie";
21  $ch = curl_init();
22
23  ob_start(); // start output buffering
24  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
25  curl_setopt($ch, CURLOPT_COOKIE, 'foo=bar');
26  curl_setopt($ch, CURLOPT_URL, $url); //set the url we want to use
27
28  $curl_content = curl_exec($ch);
29  curl_close($ch);
30
31  var_dump( $curl_content );
32?>
33===DONE===
34--EXPECTF--
35*** Testing curl with cookie ***
36string(3) "bar"
37===DONE===
38
39