469,631 Members | 1,218 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

fopen and cookies?

Hi,

I'm trying to use fopen to open a remote page. I found a page that
doesn't work, and it's because the page requires cookies. Is there a
way in PHP to pass cookies to a remote host?

Here is my source test code:
Code:

<html><head><title>fopen test</title></head>
<body>
<?
$url = "http://www.bestbuy.com/";
$f = fopen($url, 'r');
if($f)
{
$page = "";
while($pre = fread($f,100000))
{
$page = $page.$pre;
}
echo "Page:<br>$page<br><br>";
}
else
{
echo "Can't open page<br>";
}

?>

</body>
</html>


If you run the script, you are supposed to get the remote page
displayed back. In this case I get an error message from Best Buy
complaining that I must enable cookies to visit the site. How can I
overcome this with PHP?

Thanks,
Grant
Jul 17 '05 #1
5 5944
In article <fv********************************@4ax.com>, Grant wrote:
I'm trying to use fopen to open a remote page. I found a page that
doesn't work, and it's because the page requires cookies. Is there a
way in PHP to pass cookies to a remote host?


Have a look at the curl module. http://www.php.net/manual

--
http://home.mysth.be/~timvw
Jul 17 '05 #2
"Grant" <Gr***@nospam.com> wrote in message
news:fv********************************@4ax.com...
Hi,

I'm trying to use fopen to open a remote page. I found a page that
doesn't work, and it's because the page requires cookies. Is there a
way in PHP to pass cookies to a remote host?


See http://www.php.net/manual/en/functio...ext-create.php
Jul 17 '05 #3
Grant <Gr***@nospam.com> wrote in message news:<fv********************************@4ax.com>. ..
Hi,

I'm trying to use fopen to open a remote page. I found a page that
doesn't work, and it's because the page requires cookies. Is there a
way in PHP to pass cookies to a remote host?


<snip>

1. http://in.php.net/curl
2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
3. http://curl.haxx.se/libcurl/php/examples/

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4
On 11 May 2004 00:34:29 -0700, ng**********@rediffmail.com (R. Rajesh
Jeba Anbiah) wrote:
Grant <Gr***@nospam.com> wrote in message news:<fv********************************@4ax.com>. ..
Hi,

I'm trying to use fopen to open a remote page. I found a page that
doesn't work, and it's because the page requires cookies. Is there a
way in PHP to pass cookies to a remote host?


<snip>

1. http://in.php.net/curl
2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
3. http://curl.haxx.se/libcurl/php/examples/


Hi, I finally got curl installed and compiled. Are there any more
examples that might help me out? The page in question I'm trying to
get is www.bestbuy.com . No matter what I do I can't get it to return
the html contents. I think I'm getting hung up on the cookies.

Any code would be much appreciated.

Thanks,
Grant
Jul 17 '05 #5
Grant <Gr***@nospam.com> wrote in message news:<ct********************************@4ax.com>. ..
<snip>
1. http://in.php.net/curl
2. http://curl.haxx.se/libcurl/php/exam...=cookiejar.php
3. http://curl.haxx.se/libcurl/php/examples/


Hi, I finally got curl installed and compiled. Are there any more
examples that might help me out? The page in question I'm trying to
get is www.bestbuy.com . No matter what I do I can't get it to return
the html contents. I think I'm getting hung up on the cookies.


Could you post your code, so that we can find what is wrong with your code/logic?

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Shaoyong Wang | last post: by
6 posts views Thread by Anonymous | last post: by
4 posts views Thread by Brian Burgess | last post: by
20 posts views Thread by Brian Burgess | last post: by
6 posts views Thread by Mark | last post: by
6 posts views Thread by Stephane | last post: by
4 posts views Thread by lucyachammond | last post: by
4 posts views Thread by Bob Bedford | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.