Login and get cookies Using CFHTTP

2.1k views Asked by At

I want to log in (https://pacer.login.uscourts.gov/csologin/login.jsf) using CFHTTP.Using Http Live Header we have collect all required parameter and post to the login url.Here is my Example Code:

<cfhttp url="#arguments.login_url#" method="post" timeout="30" redirect="no" resolveURL="yes" useragent="Mozilla/5.0">
  <cfhttpparam name="login" value="login" type="formField">
  <cfhttpparam name="login:loginName"value="xxxx"type="formField">                      
  <cfhttpparam name="login:password" value="xxxx" type="formField">
  <cfhttpparam name="login:clientCode" value="" type="formField">
  <cfhttpparam name="login:Aj_idt206" value="" type="formField">
  <cfhttpparam type="formField" name="javax.faces.ViewState" value="stateless">
</cfhttp>

After trying above code we have get same login page content.How to log in above Mention Url and collected all cookies,session after login. Anyone have any ideas or any clue or any other method in CF?

thanks

Atu

1

There are 1 answers

0
Jan BrĂ¼nemann On

I think you first have to do a get request to start a new session and then do the post using the JSESSIONID you got from the get request:

<cfhttp url="https://pacer.login.uscourts.gov/csologin/login.jsf" method="get" timeout="30" redirect="no" resolveURL="yes" useragent="Mozilla/5.0">
</cfhttp>

<cfset setcookies = cfhttp['Responseheader']['set-cookie']>

<cfhttp url="https://pacer.login.uscourts.gov/csologin/login.jsf" method="post" timeout="30" redirect="no" resolveURL="yes" useragent="Mozilla/5.0">
    <cfhttpparam name="login" value="login" type="formField">
    <cfhttpparam name="login:loginName"value="xxxx"type="formField">                      
    <cfhttpparam name="login:password" value="xxxx" type="formField">
    <cfhttpparam name="login:clientCode" value="" type="formField">
    <cfhttpparam name="login:Aj_idt206" value="" type="formField">
    <cfhttpparam type="formField" name="javax.faces.ViewState" value="stateless">
    <cfhttpparam type="header" name="Cookie" value="#setcookies#">
</cfhttp>