curl-and-php
Cookie in cURL.
Date: Wed, 17 Sep 2008 20:16:42 +0530
Please take a look at the code below:
$method = $request[ $i ][ 'Method' ];
$url = $request[ $i ][ 'URI' ];
$curl = curl_init( 'http://' . $_SERVER[ 'SERVER_NAME' ] . $url );
curl_setopt( $curl, CURLOPT_HEADER, 2 );
//When I uncomment
//curl_setopt( $curl, CURLOPT_COOKIE, session_name() . '=' .
$_COOKIE[session_name()] . '; domain=192.168.0.76; path=/' );
curl_setopt( $curl, CURLOPT_HTTPHEADER, $request[ $i ][ 'Headers' ] );
if ( $method == 'POST' )
{
curl_setopt( $curl, CURLOPT_POST, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $request[ $i ][ 'Content' ] );
}
else if ( $method != 'GET' )
{
curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, $method );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $request[ $i ][ 'Content' ] );
}
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$strResponse = curl_exec( $curl );
**********************************************************************************************
When I uncomment the line
curl_setopt( $curl, CURLOPT_COOKIE, session_name() . '=' .
$_COOKIE[session_name()] . '; domain=192.168.0.76; path=/' );
I am not getting response, Timed out.
A session will be created when client sends a request to server A. The same
session should be used for the requests that are sent (using cURL) from A to
A. Otherwise data will not be returned in the requests going from A to A.
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-09-17