By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,649 Members | 696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,649 IT Pros & Developers. It's quick & easy.

PHP accept cookies?

P: n/a
Okay, so I want to do this THANG, which involves some fairly ugly
screenscraping since it's a mashup with another site that doesn't have
friendly, mashable, controls.

Problem- I need to log into the site from a PHP script- and when I
send my login info, it responds with the following:

Download the Flash plugin.
You must have cookies enabled to use the site. Please enable cookies
and click here.

The possible causes of this problem are:

* Your browser is setup to block cookies.
* Your firewall is setup to block cookies.
* Your AntiVirus program is setup to block cookies.

I gather the server is using something to test for flash, and then
settignt he appropriate cookie. I don't care about the flash- all i
need is the HTML on the next page. So how do I accept its cookie so
that I can scrape this?

(Ironically, none of this is strictly necessary for the mashup- but I
have to do this part to verify login names in order to keep users from
messing with other users' accounts. Clearly I am a saint for enduring
this unnecessary suffering.)

-Derik

May 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Re********@aol.com wrote:
Problem- I need to log into the site from a PHP script- and when I
send my login info, it responds with the following:
If you are using cURL, use curl_setopt()
http://us2.php.net/manual/en/function.curl-setopt.php with
CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE to ensure cookies sent back get
carried over.

You can also use a PHP browser emulator like SimpleTest to get similar
functionality.

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGXijZqTO+fYacSNoRAi/IAJ9jW5zS/eVbl5iZ/Ha7XD7dvH/YZACfX+z3
gw+wQFxi5UhjWB8MAgs5Wl4=
=rkpC
-----END PGP SIGNATURE-----
May 31 '07 #2

P: n/a
On May 30, 8:46 pm, "Edward Z. Yang" <edwardzy...@thewritingpot.com>
wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ReGenes...@aol.com wrote:
Problem- I need to log into the site from a PHP script- and when I
send my login info, it responds with the following:

If you are using cURL, use curl_setopt()http://us2.php.net/manual/en/functio...setopt.phpwith
CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE to ensure cookies sent back get
carried over.

You can also use a PHP browser emulator like SimpleTest to get similar
functionality.
Although I can't say, for sure, I suspect the problem may be more
complicated then that.

What if the cookies aren't being set with HTTP headers but rather,
with javascript? cURL won't catch them, then, and unless SimpleTest
has a full blown javascript parser, I doubt it will, either.

So what if the Flash file, itself, is setting the cookies?

Well, I guess you could always decode the Flash file and create your
own "cookiejar" from that...

The Flash specifications are available here:

http://www.adobe.com/licensing/

(scroll down to "Macromedia Flash (SWF) and Flash Video (FLV) File
Format Specification (Version 8)")

May 31 '07 #3

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

yawnmoth wrote:
Although I can't say, for sure, I suspect the problem may be more
complicated then that. [snip]
If that is indeed the case, I would throw up my hands and give up. It
should be fairly simple to determine with a little request tampering on
the site.

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGXjhdqTO+fYacSNoRAusTAJ0eV4oAINexvp0IXSVZhd WiqmwaTACfZH7J
RMAj4wF+4qJQPXbywCQfwbI=
=3x+v
-----END PGP SIGNATURE-----
May 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.