PHP Classes

File: get_using_cookie.php

Recommend this page to a friend!
  Classes of Schroetter Christian   PHP Curl HTTP Wrapper   get_using_cookie.php   Download  
File: get_using_cookie.php
Role: Example script
Content type: text/plain
Description: Sample file
Class: PHP Curl HTTP Wrapper
Send HTTP requests with Curl and cache the results
Author: By
Last change:
Date: 10 years ago
Size: 973 bytes
 

Contents

Class file image Download
<?php
   
include('./curl.wrapper.php');

   
$curl = new CCurlWrapper();
    if(
$curl->InitEx() === false)
        die(
'Unable to init the CURL library' . "\n");

   
$mag_num = 159;

   
// request
   
$content_no_cookie = $curl->Exec('http://www.auchan.fr/magasin/recherche/selectMagasin.jsp?selectStore=' . $mag_num);

   
// cookie's JAR
   
$curl->SetCookieFile('./cookie.txt');
   
// use new cookie for every request (the content of the 'cookie.txt' is ignore)
   
$curl->SetCookieSession(true);

   
$curl->SetCookie(array('AuchanEM=||||||', 'AuchanFR.shop=' . $mag_num . '||'));
   
$content_cookie = $curl->Exec('http://www.auchan.fr/magasin/recherche/selectMagasin.jsp?selectStore=' . $mag_num);

   
// file_put_contents('./content_no_cookie.html', $content_no_cookie);
    // file_put_contents('./content_cookie.html', $content_cookie);

    // the difference is top left
        // "TROUVEZ MON MAGASIN" (Find my store) without cookie
        // "MON MAGASIN : GRASSE(changer)" (My store : GRASSE(change) with cookie

?>