Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cfhttp - access response URL parameters

Posted on 2010-09-03
11
Medium Priority
?
881 Views
Last Modified: 2012-05-10
I am using <cfhttp to login to an interface (passing username and password with <cfhttpparam.

I need to access the URL variables (Query String) of the page displayed after login.  In other words.. if I login manually, after logging in, I am displayed a page which has the session id in the query string. I want to access this query string when logging in via <cfhttp.

Does anyone know if/how I can access the QueryString or URL of the page returned from a cfhttp POST request?

Many Thanks

Jason
0
Comment
Question by:Jay1607
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 33600140
My guess - this isn't possible with a cfhttp POST.  If you really needed the functionality, I suspect you'd need a different tool.  It might be possible with java:
http://stackoverflow.com/questions/1456987/httpclient-4-how-to-capture-last-redirect-url

If it were a GET request, you'd have options.  (But what login page would use GET? ;-)
http://www.bennadel.com/blog/934-Ask-Ben-Handling-Redirects-With-ColdFusion-CFHttp.htm



0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 33600276
May be use can you use TRACE method, insead of "GET" or "POST" method.

Using TRACE method we can get cfide and cftoken from a coldfusion server and you can use those ids to send automated requests to CF server. With cfid and cftoken you get more session details.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33600458
That's a good thought.  But I didn't think it works combination with POST.  AFAIK they're mutually exclusive, which might cause a problem.  I'm assuming the redirect only happens when the login is successful.  Meaning the request type would have to be a POST (with those form fields) for there to even be anything to TRACE.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 33600500
Not tested but check the parameter: redirect="No"
      
From description:
=======================
If the response header includes a Location field, determines whether to redirect execution to the URL specified in the field.

    * Yes redirects execution to the specified page.
    * No stops execution and returns the response information in the cfhttp variable, or throws an error if the throwOnError attribute is True.

The cfhttp.responseHeader.Location variable contains the redirection path. ColdFusion follows a maximum of four redirects on a request. If there are more, ColdFusion functions as if redirect ="no".
=======================

That mean: your queryString is after the response in the variable: cfhttp.responseHeader.Location

 
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33600747
Yeah, I was thinking about that too.  But I wasn't sure the session would still be valid. Definitely worth trying though, cause I could be wrong.
0
 

Author Closing Comment

by:Jay1607
ID: 33602634
Zvonko, I dropped in redirect="No", and voila!!! there was the location var with the url variable I needed!

Thank you!!
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 33603318
You are welcome <|:-)
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33606489
@Jay1607

So the session value referenced is still valid even though the full login (ie redirect) is canceled?  Never know when I might need this in the future, so want to verify it works as desired.
0
 

Author Comment

by:Jay1607
ID: 33608245
Correct.  It works exactly as needed..
0
 

Author Comment

by:Jay1607
ID: 33608247
Worth pointing out.. I'm not logging into a CF App.. I think it's an old Delphi app..
0
 
LVL 52

Expert Comment

by:_agx_
ID: 33609363
@Jay1607,

Great, thanks!

Good point about the app though.  There's probably lots of different handling for sessions.  So it may well vary by platform.

Cheers
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question