cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Re: libcurl and cookies

From: Georges EL OJAIMI <g-ojaimi_at_cyberia.net.lb>
Date: Sat, 26 Apr 2008 8:01:21 +0300

Hello,

> I guess the new cURL version stores cookies differently.

Is there a manual to know how these 2 versions differ in storing the cookie values

Best regards,
Georges

>
> From: "Stephen Pynenburg" <spynenburg_at_gmail.com>
> Date: 2008/04/26 Sat AM 02:51:26 EAT
> To: "curl with PHP" <curl-and-php_at_cool.haxx.se>
> Subject: Re: libcurl and cookies
>
> Just a thought - not sure if it's the problem:
> You have:
> [4] => xxx.xxx.xxx.xxx FALSE / FALSE 0 PHPSESSID
> a8ebdd0ba4956debffb9ae10bf9ca6e7
>
> [5] => .xxx.xxx.xxx.xxx TRUE /smf/ FALSE 1209133768 SMFCookie399
> a%3A4%3A%7Bi%3A0%3Bs%3A1%3A%222%22%3Bi%3A1%3Bs%3A40%3A%22dc9c29343e14d52ae8cea170d114038e2a4edb4c%22%3Bi%3A2%3Bi%3A1209133768%3Bi%3A3%3Bi%3A3%3B%7D
>
> I noticed that you're using explode("\t", $cookie_data); however as you see
> in the above cookies, it's probably not working properly. You might want to
> try using preg_match instead, with parenthesized substrings - it will be
> more custom and precise.
>
> I guess the new cURL version stores cookies differently.
>
> -Stephen
>
> 2008/4/25 Georges EL OJAIMI <G-OJAIMI_at_cyberia.net.lb>:
>
> > Hello,
> >
> > I know that, I already replace it :)
> >
> > For instance I tried to print the cookie value, on the localhost, it prints
> > *http://www.netscape.com/newsref/std/cookie_spec.html* and on the hosting
> > company *http://curlm.haxx.se/rfc/cookie_spec.html*
> >
> > *localhost*
> > Array ( [0] => # Netscape HTTP Cookie File [1] => # *
> > http://www.netscape.com/newsref/std/cookie_spec.html* [2] => # This file
> > was generated by libcurl! Edit at your own risk. [3] => [4] =>
> > xxx.xxx.xxx.xxx FALSE / FALSE 0 PHPSESSID a8ebdd0ba4956debffb9ae10bf9ca6e7
> > [5] => .xxx.xxx.xxx.xxx TRUE /smf/ FALSE 1209133768 SMFCookie399
> > a%3A4%3A%7Bi%3A0%3Bs%3A1%3A%222%22%3Bi%3A1%3Bs%3A40%3A%22dc9c29343e14d52ae8cea170d114038e2a4edb4c%22%3Bi%3A2%3Bi%3A1209133768%3Bi%3A3%3Bi%3A3%3B%7D
> > [6] => )
> >
> > *hosting company*
> > Array ( [0] => # Netscape HTTP Cookie File [1] => # *
> > http://curlm.haxx.se/rfc/cookie_spec.html* [2] => # This file was
> > generated by libcurl! Edit at your own risk. [3] => [4] => xxx.xxx.xxx.xxx
> > FALSE / FALSE 0 PHPSESSID 3f66da919351904794910d1d69a448af [5] =>
> > .xxx.xxx.xxx.xxx TRUE /smf/ FALSE 1209133794 SMFCookie399
> > a%3A4%3A%7Bi%3A0%3Bs%3A1%3A%222%22%3Bi%3A1%3Bs%3A40%3A%22dc9c29343e14d52ae8cea170d114038e2a4edb4c%22%3Bi%3A2%3Bi%3A1209133794%3Bi%3A3%3Bi%3A3%3B%7D
> > [6] => )
> >
> > Best regards,
> > Georges
> >
> >
> > YupLounge website analyse en optimalisatie wrote:
> >
> > Hello georges
> >
> > Does http://localhost/smf/index.php?action=login2
> > Work for your hoster? I can't believe that.
> > I believe that usinghttp://www.yourdomainname.com/smf/index.php?action=login2
> > Will give no problems.
> >
> > On your local machine you can use localhost, will on your hosting machine
> > you can't normally.
> >
> > willem
> > -----Oorspronkelijk bericht-----
> > Van: curl-and-php-bounces_at_cool.haxx.se
> > [mailto:curl-and-php-bounces_at_cool.haxx.se <curl-and-php-bounces_at_cool.haxx.se>] Namens Georges EL OJAIMI
> > Verzonden: donderdag 24 april 2008 23:40
> > Aan: curl-and-php_at_cool.haxx.se
> > Onderwerp: libcurl and cookies
> >
> > I am writing a function to automatically connect to simple machine
> > forum, however on my locahost I have PHP Version 4.3.3 and libcurl/7.10.5
> > However on my hosting provider server, I have PHP Version 5.2.5 and
> > libcurl/7.18.0
> >
> > The following code works very well on my locahost but on the hosting
> > provider the cookie is not being transfered.
> > Is there any problem with version 7.18.0 of libcurl and how can I
> > overcome this problem?
> >
> > Best regards,
> > Georges
> >
> > function checkLogin($pu, $pp)
> > {
> > $post_data = array();
> >
> > $post_data['user'] = $pu;
> > $post_data['passwrd'] = $pp;
> > $post_data['cookielength'] = 60;
> > $post_data['hash_passwrd'] = "";
> >
> > $cookie_new = tempnam("/tmp","NHO");
> >
> > $ch = curl_init();
> > curl_setopt($ch, CURLOPT_URL, "http://localhost/smf/index.php?action=login2" <http://localhost/smf/index.php?action=login2>);
> > curl_setopt($ch, CURLOPT_POST, 1 );
> > curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
> > curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_new);
> > curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_new);
> > curl_setopt($ch, CURLOPT_HEADER,1);
> > curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> >
> > $postResult = curl_exec($ch);
> >
> > if (curl_errno($ch))
> > {
> > return false;
> > }
> >
> > curl_close($ch);
> >
> > $cookie_status = array();
> > $cookie_contents = file_get_contents($cookie_new);
> >
> > if(file_exists($cookie_new))
> > {
> > unlink($cookie_new);
> > }
> >
> > $cookie_contents_array = explode("\n",$cookie_contents);
> >
> > // print_r ($cookie_contents_array);
> >
> > for($i = 0; $i < count($cookie_contents_array); $i++)
> > {
> > if(strpos($cookie_contents_array[$i],"localhost")!==false)
> > {
> > $cookie_array = explode("\t",$cookie_contents_array[$i]);
> >
> > if($cookie_array[4]!=0)
> > {
> >
> > header("Set-Cookie:".$cookie_array[5]."=".$cookie_array[6].";
> > expires=".date("r",$cookie_array[4])."; path=/",false);
> > }
> > else
> > {
> >
> > header("Set-Cookie:".$cookie_array[5]."=".$cookie_array[6].";
> > path=/",false);
> > }
> > }
> > }
> >
> > header("Set-Cookie: PHPSESSID=".session_id()."; path=/",false);
> >
> > return true;
> > }
> >
> > _______________________________________________http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> >
> >
> > _______________________________________________http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> >
> >
> >
> > _______________________________________________
> > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> >
> >
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-04-26