473,802 Members | 2,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><ti tle>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 6396
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.c om> wrote in message
news:fv******** *************** *********@4ax.c om...
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.c om> 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**********@re diffmail.com (R. Rajesh
Jeba Anbiah) wrote:
Grant <Gr***@nospam.c om> 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.c om> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2975
by: Shaoyong Wang | last post by:
Dear All, I want to write a simple PHP code to verify whether a given list of URLs is broken or not. The URLs given have various formats, for example, http://www.afro.com/history/history.html http://www.worldhistorycompass.com/index.htm http://www.afup.org/article.php3?id_article=242 fsockopen(...) only accepts target format (like www.yahoo.com etc), so I
6
3120
by: Anonymous | last post by:
Hi! I've got an unusual problem here. I'm trying to write a PHP script that behaves like a web client. Why? I want to automatically check specific URLs for changes. I'm using file_get_contents(URL) to read the pages and this seems to work just fine as long as there are no logins, sessions or cookies. But I'm getting a new PHPSESSID from the site whenever I get a new page
4
3886
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any new site I goto seems to prompt me to store their cookie. The other is Pocket IE on Pocket PC 2002, with the cookies set to 'enabled'. My problem is that the cookies dont seem to be being written with my ASP. I dont get the prompt to store...
20
3562
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
6
3061
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a cookie (say Response.Cookies ("TEST")) and you have a query string variable &test=x or &Test=x and you get Request.QueryString to parse the query string, the cookie that gets dropped matches the case of the query string, not what your code says. ...
8
2345
by: CDARS | last post by:
Hi all, I have a confusing question on ASP.NET cookies usage: 1> Response.Cookies("test").value = Now 2> Response.Write(Request.Cookies("test").value) 3> 4> Response.write("<hr>") 5> 6> Response.Cookies("test").value = Now.AddDays(10)
6
8854
by: Stephane | last post by:
Hi, I have a login page where if the user wants his access codes to be saved are set into a cookie. In the logout page, I want to delete those cookies. I tried this and this is not working at all: if (Request.Cookies != null && Request.Cookies != null) { Response.Cookies.Value = null;
4
2880
by: lucyachammond | last post by:
I have a 3rd party real-estate website written in php. I would like to call an asp script on a separate webserver each time a new real-estate item is added to the database on the php site. The asp script updates a sql server database for another site and once the page has been called, I do not need any return information from it. I have searched the groups but cannot find a definitive way of making the call to the asp script - I am a...
4
1906
by: Bob Bedford | last post by:
Hi all, I'm trying to pass a fopen() ressource result as a parameter. $x=fopen($filename); header('location:myfile.php?ressource='.$x); but it doesn't seem to work. How to do so ?
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10532
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10302
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10281
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3789
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.