Re: CURL and $_SESSION problem

From: Pedro Graca (hexkid_at_hotpop.com)
Date: 07/10/04


Date: 10 Jul 2004 14:54:17 GMT


["Followup-To:" header set to comp.lang.php.]
Phil Powell wrote:
>
> "Pedro Graca" <hexkid@hotpop.com> wrote in message
> news:slrnceuhcm.16d.hexkid@ID-203069.user.uni-berlin.de...
>> If Mozilla can do it, so can you with telnet!
>
> Can't with telnet.
>
> telnet <server> <port>
>
> Produces this error:
>
> Connection refused
>
> Apparently the remote server has telnet blocked

Well ... maybe there's a proxy between Mozilla and the server.

>> Let's assume you got the cookie and have it saved in $scraped_cookie.
>> Precede next curl_exec() call with
>>
>> curl_setopt($ch, CURLOPT_COOKIE, $scraped_cookie);
>>
>> This $scraped_cookie will be something like
>> "PHPSESSID=0123456789abcdeffedcba9876543210"
>> (without the quotes, of course), with no spaces before or after, with no
>> semi-colons anywhere, with no line breaks.
>
> Ok did just that as well (will reproduce the code later as I do not have
> direct access to it from here at home), and produced a query string like
> this:
>
> image_catalog=phillip.powell%2Emyphpwebsite.com&PHPSESSID=0123456789abcdeffe
> dcba9876543210
>
> Which is fine, and preceded the curl_exec() call with
>
> curl_setopt($ch, CURLOPT_COOKIE, $qs);
>
> Where $qs = the query string you see above..

Oops! $qs must not have all that. Strip "image_catalog=...website.com&"
from it before setting it up as the cookie, or if you need the two
cookies they should be separated by a colon, not the ampersand:

    curl_setopt($ch, CURLOPT_COOKIE, str_replace('&', ':', $qs));

maybe that works ... I'm not sure about the %2E in there.

> But the results would indicate that the second curl_exec(), after setting
> the set-cookie HTTP headers with the previously obtained session id from
> "index.php", would still NOT get the session anyway!

It's not the expected cookie, so the server starts a brand new
connection with a brand new cookie.

-- 
USENET would be a better place if everybody read:   | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html  | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html    | header, textonly |
http://www.expita.com/nomime.html                   | no attachments.  |


Relevant Pages

  • Re: Cookies not being sent by IIS
    ... Try PuTTY for telnet. ... >>Temporary Internet Folders and look for the downloaded cookie. ... >>first server, the cookie shows up in the Temporary Internet Folders. ... >>I will test telnetting to port 80. ...
    (microsoft.public.inetserver.iis.activeserverpages)
  • Re: Cookies not being sent by IIS
    ... Try PuTTY for telnet. ... >>Temporary Internet Folders and look for the downloaded cookie. ... >>first server, the cookie shows up in the Temporary Internet Folders. ... >>I will test telnetting to port 80. ...
    (microsoft.public.inetserver.iis)
  • Re: CURL and $_SESSION problem
    ... >> If Mozilla can do it, so can you with telnet! ... maybe there's a proxy between Mozilla and the server. ... It's not the expected cookie, so the server starts a brand new ...
    (comp.lang.php)
  • Re: CURL and $_SESSION problem
    ... If you don't specify the port, it'll default to port 23, which probably ... so can you with telnet! ... The cookie keeps changing ... ... the server will generate a new one. ...
    (comp.lang.php)
  • Re: CURL and $_SESSION problem
    ... If you don't specify the port, it'll default to port 23, which probably ... so can you with telnet! ... The cookie keeps changing ... ... the server will generate a new one. ...
    (alt.php)