tags:

views:

71

answers:

1

hiii..

i am tring to read a cookie value whic i got after login by sending post request then i want to sent this cookie value with post request using curl to another action . but after sending this when i am trying to see all posted header it does display that i have send any cookie value . this value is not available to my posted url so not able to access their information due to authentication. plz tell me where i have done wrong

$URL1 = "http://www.getinf.com/iconf/user?action=buGroup";
$postfields1 = "device=mapp&type=ajax&name1=ra&cc1=91&min1=90name2=imm&cc2=91&min2=97";

// sends a post request
$ch1 = curl_init();   
curl_setopt($ch1, CURLOPT_URL,$URL1); 
curl_setopt($ch1, CURLOPT_POST, 1);

curl_setopt($ch1,CURLOPT_cookie,'JSESSIONID=199FFF6355DEA87F3D72E692E7514AD2');
curl_setopt($ch1, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch1, CURLOPT_HEADER,true);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $postfields1);
$result = curl_exec($ch1);
print_r(headers_list());// displays all post request data
$ret = ReturnVal($result);
print_r(get_headers($URL1, 1)); // 
curl_close ($ch1);

so whats wrong in this code so that it is not sending JSESSIONID value as a cookie .plz help me ...i

A: 

Check the comments (or search "cookie") on this page in the php docs:

Whats not mentioned in the documentation is that you have to set CURLOPT_COOKIEJAR to a file for the CURL handle to actually use cookies, if it is not set then cookies will not be parsed.

Typeoneerror
i am new in using curl so can you plz tell me how to set this cookiejar.
ricky
well thanks a lot as after setting CURLOPT_COOKIEJAR its working....
ricky
nice, ricky! vote me up! :)
Typeoneerror