question about php/curl

Discussion in 'PHP' started by coun_vincent, Nov 25, 2009.

  1. #1
    Hi Everybody,

    i wanna ask about something in PHP/CURL. when i set my script to open a specific website using curl and this site sets a cookies
    i want to know where's the cookies saved ? server or client side.
    also is there any curl option that saves or copy this cookies in an array or soemthing similar that can allow me access the cookie that comes from the remote url?
     
    Last edited: Nov 25, 2009
    coun_vincent, Nov 25, 2009 IP
  2. papsyface

    papsyface Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In the majority of cases, the cookie is stored client-side (in a text file). It's possible for the server to store a cookie server-side, but it's more of a hack than anything. For example, instead of saving settings in a cookie stored on the user's machine - it's possible to store them on the server-side and associate those settings with the user's IP address. It's not really common, but it does happen.

    In those cases, there's not much you can do as far as viewing/editing the cookie goes.

    The easiest way is call curl_setopt(). For example:

    curl_setopt($ch, CURLOPT_COOKIEJAR, "digitalpoint-cookies.txt");
    curl_setopt($ch, CURLOPT_COOKIEFILE, "digitalpoint-cookies.txt");

    cURL will load the cookies from the file specified with CURLOPT_COOKIEJAR, and it will save the cookies (usually when the connection is closed) to the file specified in COOKIEFILE. To avoid confusion, it's best to just specify the same filename for both.
     
    papsyface, Nov 25, 2009 IP
  3. coun_vincent

    coun_vincent Well-Known Member

    Messages:
    803
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    130
    #3
    thank you its working
     
    coun_vincent, Dec 3, 2009 IP