I know that this question have been asked many times before in Stack-overflow but none of the answers solved my problem.
I am writing a php script that uses curl to remotely browse JSP site: here is my code:
<?php
$loginUrl = 'http://ccc.hyundai-motor.com/servlet/ccc.login.CccLoginServlet';
$sh = curl_share_init();
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SHARE, $sh);
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'the post data including my username and password and other hidden fields');
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_SHARE, $sh);
curl_setopt($ch2, CURLOPT_URL,'http://ccc.hyundai-motor.com/servlet/ccc/admin/user/UserInfoServlet?cmd=myUserInfo');
curl_setopt($ch2, CURLOPT_COOKIEFILE,'cookie.txt');
curl_setopt($ch2, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch2, CURLOPT_VERBOSE, true);
$result = curl_exec($ch2);
print $result;
curl_share_close($sh);
curl_close($ch);
curl_close($ch2);
?>
When I execute the code the cookie file is created but i get an error "session lost, please re-login".