OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Get cookies of external website with PHP

  • Thread starter Thread starter Barry Kooij
  • Start date Start date
B

Barry Kooij

Guest
I'm trying to get all cookies of a website into an array in PHP. The goal of the script is to enter a website url and let the script check what cookies are set.

I've tried using HTTP_Request like this:

Code:
$req = new HTTP_Request($url);
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->sendRequest();
$cookies = $req->getResponseCookies();

But this is only returning the server-side set cookies (like a session ID). I would also like to recieve cookies that are set with javascript, like the Google Analytics cookies.

I know this is possible because the website: http://www.cookie-checker.com/ is able to do so. To be sure the "cookie-checker" website is really parsing javascript set cookies and not just parsing known javascript source url, I've scanned a test website which wrote a dummy javascript cookie. They detected this cookie succesfully (incl. name, value and expiration date).

Any help would be very much appreciated!

Thanks in advance.

Barry

<p>I'm trying to get all cookies of a website into an array in PHP. The goal of the script is to enter a website url and let the script check what cookies are set.</p>

<p>I've tried using <a href="http://pear.php.net/package/HTTP_Request/" rel="nofollow">HTTP_Request</a> like this:</p>

<pre><code>$req = new HTTP_Request($url);
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->sendRequest();
$cookies = $req->getResponseCookies();
</code></pre>

<p>But this is only returning the server-side set cookies (like a session ID). I would also like to recieve cookies that are set with javascript, like the Google Analytics cookies.</p>

<p>I know this is possible because the website: <a href="http://www.cookie-checker.com/" rel="nofollow">http://www.cookie-checker.com/</a> is able to do so. To be sure the "cookie-checker" website is really parsing javascript set cookies and not just parsing known javascript source url, I've scanned a test website which wrote a dummy javascript cookie. They detected this cookie succesfully (incl. name, value and expiration date).</p>

<p>Any help would be very much appreciated!</p>

<p>Thanks in advance.</p>

<p>Barry</p>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top