Re: Cookie access with CLI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/6/13 David Česal <David@xxxxxxxx>:
> Hello,
>
> I'm trying to access (from CLI) some website, where login is required.
> Please, is it possible to set/save some cookies first (login session
> information) and then access the website as logged user? All through CLI.
>
>
>
> Thank you very much for any information.
>
>
>
> David Cesal
>
>

Beside cURL, you can also use stream contexts to get/set the cookie
for subsequent requests.

http://docs.php.net/stream_context_create
http://docs.php.net/stream_get_meta_data
http://docs.php.net/manual/en/context.http.php

Essentially, you create a context when you send the data (this will
allow you to POST data for a file_get_contents() call).

Then you get the meta data from the response.

Then you put the cookie you received into the context you will use to
continue in communication.

If you set up the default context in this way, then you don't need to
supply the context to every file command.

See the user notes on file_get_contents regarding routing calls
through an NTLM proxy. By creating a default context, all my code was
routed through an NTML proxy. PHP didn't support NTLM authentication
when I wrote the note (not sure it does yet, but my requirement
changed).

By using a default context, I have 1 place to edit any code (in my
auto_prepend.php script).


Richard.

-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux