Login and Receiving Cookies Using CFHTTP
I want to login ( https://pacer.login.uscourts.gov/csologin/login.jsf ) using CFHTTP. Using Http Live Header, we collect all the required parameters and publish the url for login. 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 flashing the code, we get the same content of the login page. How to login above url and collect all cookies, session after login. Anyone have any ideas or any clue or some other method in CF?
thank
Atu
+3
source to share
1 answer
It seems to me that you first need to execute the request get
to start a new session and then do post
with the help you JSESSIONID
got from the request get
:
<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>
0
source to share