PHP + cURL - Post & Cookies

slinkz

New Member
Messages
1
Reaction score
0
Points
0
Hello, I need to use cURL to post some data and send cookies (in the same request).

I have no idea how to do this so please help!

Thanks,
tenx23
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Topic 1: Posting data

PHP:
<?php

$ch = curl_init("http://example.com/curl_target.php");

curl_setopt($ch, CURLOPT_HEADER, 0);  // don't want header info
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  //  make the result the return value of curl_exec

curl_setopt($ch, CURLOPT_POST, 1);  //  do a POST, not a GET

curl_setopt( $ch,   CURLOPT_POSTFIELDS ,     'para1=val1&para2=val2' ); // add the POST info

$output = curl_exec($ch);      // send  it

curl_close($ch); // clean up

echo $output;  // show the response
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Start with the documentation for curl_setopt, which lists the options you should set. You can use curl_setopt_array rather than curl_setopt to set multiple options simultaneously, but the documentation for the latter is what you need to read.
 
Top