Solved

cfhttp - access response URL parameters

Posted on 2010-09-03
11
871 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

734 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