Solved

cfhttp - access response URL parameters

Posted on 2010-09-03
11
878 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
Industry Leaders: 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
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 …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

626 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