Jump to content

php curl cookie problem


respec

Recommended Posts

Hello,

 

I got stucked with a trivia problem (I believe) in my script, but can't find answer at any forums. Hopping you guys may help a bit. Let me explain:

 

I am writing a short php-curl script for testing our website developments. It supposes to connect to our website's test pages and display the content.

 

The pages checks session and visitors cookies to hide (on any multiple visit) certain div on the page, containing the keyword. Therefore for testing purposes we need to connect via anonymous proxies to simulate original visits from outside.

 

The part with analysis of the fetched content of keyword match works flawless.

The page-load in a browser is also working well.

 

The only problem I have is this:

 

When I am connecting to the specific testpage via anonymous proxies - and changing the proxy address for each request - the page recognizes my identity and hides the div. When using two IPs for two requests, the page "knows" it is the 2nd time.

 

The problem disappears if I turn off the session and visitor cookies as admin of the websites, therefore I think it has to do something with managing cookies in curl sessions.

 

I played a lot with different cookie setups, it did not count. I am still getting the same visitor ID in header's cookies, and I need to "fresh" for the page. Please help:

 

//----------------------------------------------------------------

$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $url);	
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, 0); 
curl_setopt ($ch, CURLOPT_PROXY, $proxyFull);  
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, $proxyUser:$proxyPass); 	
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt ($ch, CURLOPT_MAXREDIRS, 5); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt ($ch, CURLOPT_HEADER, 1); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 
curl_setopt ($ch, CURLOPT_ENCODING, ""); 
curl_setopt ($ch, CURLOPT_TIMEOUT, $curlTO); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $curlRuntimeTO); 
curl_setopt ($ch, CURLOPT_USERAGENT, $UAgent); 
curl_setopt ($ch, CURLOPT_REFERER, $Referer); 
curl_setopt ($ch, CURLOPT_COOKIESESSION, true); 

$content = curl_exec ($ch);
$curl_info = curl_getinfo($ch);
curl_close ($ch);

echo $content;

//----------------------------------------------------------------

 

thank you and have good days

 

Tom Respec

WebNow, Inc.

 

 

Link to comment
https://forums.phpfreaks.com/topic/108306-php-curl-cookie-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.