title: j_security authentication using cURL
body: <p>I'm using Tomcat JDBCRealm to authenticated users when they follow a protected page. The authentication works properly when reaching a protected page. Now I'd like to automate this process using cURL. I've written the code below but it doesn't work :</p>
  
  <pre><code>$domainUrl = "http://mydomain.com/protectedArea?j_username=john&amp;j_password=doe";
  $ch = curl_init ();
  curl_setopt ( $ch, CURLOPT_URL, $domainUrl );
  //curl_setopt ( $ch, CURLOPT_POST, true );
  //curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post );
  curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); 
  curl_setopt ( $ch, CURLOPT_TIMEOUT, 7 );
  
  $output = curl_exec ( $ch );
  curl_close ( $ch );
  </code></pre>
  
  <p>In tomcat log we can see only http GET :</p>
  
  <pre><code>[07/Aug/2012:11:51:24 +0200] GET http://mydomain.com/protectedArea?j_username=john&amp;j_password=doe HTTP/1.1 200 1618
  </code></pre>
  
  <p>whereas we should have something like that : </p>
  
  <pre><code>[07/Aug/2012:11:57:06 +0200] GET http://mydomain.com/protectedArea?j_username=john&amp;j_password=doe HTTP/1.1 200 1516
  [07/Aug/2012:11:57:06 +0200] POST http://mydomain.com/j_security_check HTTP/1.1 302 -
  </code></pre>
  
  <p>Does someone have any idea?</p>
  
  <p>Thanks for your help</p>
  
  <p>Regards</p>