Solved

cfhttp - access response URL parameters

Posted on 2010-09-03
11
862 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
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now