When you do an <cfhttp> request, you may or may not receive cookies FROM the
server.  To determine if you have, simply look at the "responseHeader".  If
you have, and you need to send those BACK to the server, that is when you
want to use the <cfhttpparam type="COOKIE"> code.  The following code
connects to a server, gets the cookies and then connects back using the
cookies that were just sent.


I have to do this quite frequently when I'm connecting to websites that use
cookies to determine whether or not to display an advertisement before
showing the page that you're really trying to access.  I hope this helps.


<cfhttp url="" http:// <http://www.whatever.com/index.html>
www.whatever.com/index.html"
useragent="Mozilla/4.0">
</cfhttp>

<!--- Take a look at the cookies that the server sent to ME --->
<cfdump var="#cfhttp.responseHeader#">

<!--- Create an array to hold the cookies that the server sent --->
<cfset cookies = ArrayNew(1)>
<cfset counter = 1>
<!--- Loop through the cookies from the response header --->
<cfloop item="currItem" collection="#cfhttp.responseHeader["Set-Cookie"]#">
    <cfset cookies[counter] = ListGetAt(
cfhttp.responseHeader["Set-Cookie"][currItem], 1, ";" )>
    <cfset counter = counter + 1>
</cfloop>


<!--- Now send the cookies back to the server on our next request --->
<cfhttp url="" http:// <http://www.whatever.com/index.html>
www.whatever.com/index.html"
    useragent="Mozilla/4.0"
    method="get">

<cfloop from="1" to="#arrayLen(cookies)#" index="x">
    <cfhttpparam type="COOKIE" name="#ListFirst(cookies[x],'=')#"
value="#ListRest(cookies[x],'=')#">
</cfloop>

</cfhttp>



-----Original Message-----
From: Chunshen Li [mailto:[EMAIL PROTECTED]
Sent: Monday, February 23, 2004 9:53 AM
To: CF-Talk
Subject: Re: Break the block, and SURVIVE, any way?

Now, I'm totally confused or have not waken up yet :)
It seems either ua problem or cookie problem or both.
But here's my take on this "fiasco", this particular case, process
flow-wise,
normally a web client sends a request to a remote web server,
the server checks ua and write some cookes to the requesters, if successful,

send back requested info/web page, else, redirect to yahoo.
Now, with my so-called spider, it sends a request to the same server
telling the server I'm whom whom with the cfhttpparam type="Header"
value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
subtag, meantime, it also tells the server, cookies, bla, bla with the
cfhttpparam type="Cookie" ...
but here it bugs me,
"cookie ah, cookie, you're supposed to be crisp
but ... :) "
Web server write cookie to requester/web client, aka ua,
but cfhttpparam type="Cookie" ... seems to say, hey, take this cookie from
us
(POST method) instead of accepting a cookie.
Is my understanding if cfhttpparam type="Cookie" incorrect?

What's the deal here?

Thanks.

>On Friday 20 Feb 2004 20:50 pm, Chunshen  Li wrote:
>> <cfhttpparam name="ua"
>> type="Header" value="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
>> It's still redirected to yahoo.  Did I miss something?
>
>It's user-agent, isn't it ? Check the RFC.
>
>--
>Tom Chiverton
>Advanced ColdFusion Programmer
>
>Tel: +44(0)1749 834997
>email: [EMAIL PROTECTED]
>BlueFinger Limited
>Underwood Business Park
>Wookey Hole Road, WELLS. BA5 1AF
>Tel: +44 (0)1749 834900
>Fax: +44 (0)1749 834901
>web: www.bluefinger.com
>Company Reg No: 4209395 Registered Office: 2 Temple Back East, Temple
>Quay, BRISTOL. BS1 6EG.
>*** This E-mail contains confidential information for the addressee
>only. If you are not the intended recipient, please notify us
>immediately. You should not use, disclose, distribute or copy this
>communication if received in error. No binding contract will result from
>this e-mail until such time as a written document is signed on behalf of
>the company. BlueFinger Limited cannot accept responsibility for the
>completeness or accuracy of this message as it has been transmitted over
>public networks.***
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to