Getting a URL form a "logged in" site

Dave Cragg dcragg at lacscentre.co.uk
Tue Dec 20 02:48:51 EST 2005


On 19 Dec 2005, at 20:30, Björnke von Gierke wrote:

> I am not sure but it seems you want to set a cookie?
> In that case read the cookie page from netscape:
> http://wp.netscape.com/newsref/std/cookie_spec.html
>
> what you need to do in rev is to get the libURLLastHTTPHeaders() it  
> should contain a line similar to this:

This should be libUrlLastRHHeaders(). This returns the headers  
received from the remote host's response. (libUrlLastHttpHeaders()  
returns the last headers used by libUrl in a request.)


> Set-Cookie: NameOfCookie=Value; path=/; expires=Wednesday, 09- 
> Nov-2006 23:12:40 GMT
>
> You need to set the httpHeaders to this line in response to keep  
> logged in,  showing that you have kept the cookie:
> Cookie: NameOfCookie=Value
>
> Beware: There are ways to have several cookies in the same request!  
> So you need to accommodate for that. Also if you get a Set-Cookie  
> header with a date before the current date, you should delete the  
> cookie.
>
> To pretend to be someone else, you need to to set the "User-Agent:"  
> header to something else using libURLSetCustomHTTPHeaders.

You should just set the httpHeaders for this as well.  
(libURLSetCustomHTTPHeaders is for setting a complete set of headers  
including the request line, and is probably only useful for things  
such as HEAD or OPTIONS requests.)

To add multiple headers to the httpHeaders, you can do something like  
this:

put "Cookie: NameOFCookie=Value" into tMyHeaders
put return & "User-Agent: specialAgentString" after tMyHeaders

set the httpHeaders to tMyHeaders

Cheers
Dave




More information about the use-livecode mailing list