Re: Using cURL to store cookie session into variable / memory

Waruna Geekiyanage <[email protected]> Fri, 31 Jan 2014 07:51:53 +0530
Newsgroups gmane.comp.web.curl.php
Organization Waruna Geekiyanage
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============1794319747==
Content-Type: multipart/alternative;
 boundary="------------040408010802000604090804"

This is a multi-part message in MIME format.
--------------040408010802000604090804
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by giant.haxx.se id s0V2M9xJ011705

Hi Michael Mikhjian,

This method worked for me perfectly when all the cookes from redirects=20
were collected and append to the cookie string.
If cookie with same name received twice, have to override the value.
Important thing is to send back all the cookies received from the domain.

Thank You,
Waruna Geekiyanage

M: +94 71 4168164
E: [email protected] <mailto:[email protected]>
MSN: [email protected]
GTalk: waruna.ns
ICQ: 225184383
Yahoo: warunans
Skype: warunans

On 1/31/2014 1:23 AM, MKNwebsolutions . wrote:
> Hi all,
>
> I stumbled upon an issue where I need to use object variables sessions=20
> to store cookies instead of on disk.  I came up with a solution where=20
> I extract the sent cookies from the headers via regex into PHP object=20
> variables.  I then resend those cookies using CURLOPT_COOKIE.
>
> This all works well, but not where there is header redirections=20
> (enabled via CURLOPT_FOLLOWLOCATION).  I noticed cookies are not=20
> carried through this method when using this manual method.
>
> So, I ended up disabling CURLOPT_FOLLOWLOCATION and manually=20
> connecting each redirection page.  However, this method does / does=20
> not work on various sites.  Some sites send multiple cookies with=20
> various flags at those header redirects - throwing off my solution.  I=20
> assume that using the CURLOPT_COOKIEJAR method interprets the flags=20
> correctly.
>
> Anyone else stumble into this issue?
> *
> *
> *
> Michael Mikhjian
> **Owner =B7 **Senior Architect / Developer*
>
> http://mkn.us
> LinkedIn <http://www.linkedin.com/profile/view?id=3D7801327> =B7 Twitte=
r=20
> <https://twitter.com/#%21/MKNwebSolutions> =B7 Facebook=20
> <https://www.facebook.com/MKNwebsolutions> =B7 Youtube=20
> <http://www.youtube.com/user/MKNwebsolutions>
>
> Mobile: _+1 248-289-0645_ =B7 Office: _+1 248-274-4643_
> Troy, Michigan
>
>
> /
> /Note: This e-mail transmission, including any attachments, is=20
> intended only for the named recipient(s) and may contain information=20
> that is privileged, confidential and/or exempt from disclosure under=20
> applicable law. If you have received this transmission in error, or=20
> are not the named recipient(s), please notify MKN Web Solutions=20
> immediately by return e-mail and permanently delete this transmission,=20
> including any attachments./
> /
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php


--------------040408010802000604090804
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Michael Mikhjian,<br>
      <br>
      This method worked for me perfectly when all the cookes from
      redirects were collected and append to the cookie string.<br>
      If cookie with same name received twice, have to override the
      value.<br>
      Important thing is to send back all the cookies received from the
      domain.<br>
      <div class="moz-signature">
        <title></title>
        <p class="MsoNormal"> <span style="font-size: 10pt;
            font-family: 'Arial','sans-serif'; color: rgb(31, 73, 125);">Thank
            You,<br>
            Waruna Geekiyanage</span> </p>
        <p class="MsoNormal"><span style="font-size: 12pt; color:
            rgb(31, 73, 125);">M:&nbsp;+94 71 4168164</span> <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);
            font-family: 'Times New Roman','serif';"> E:</span> <a
            href="mailto:[email protected]"> <span style="color: blue;
              font-family: 'Calibri','sans-serif';">[email protected]</span></a>
          <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);">MSN:</span>
          <span style="font-family: 'Calibri','sans-serif'; color:
            blue;"><a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a></span> <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);">GTalk:</span>
          <span style="font-family: 'Calibri','sans-serif'; color:
            blue;">waruna.ns</span> <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);">ICQ:</span>
          <span style="font-family: 'Calibri','sans-serif'; color:
            blue;">225184383</span> <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);">Yahoo:</span>
          <span style="font-family: 'Calibri','sans-serif'; color:
            blue;">warunans</span> <br>
          <span style="font-size: 12pt; color: rgb(31, 73, 125);">Skype:</span>
          <span style="font-family: 'Calibri','sans-serif'; color:
            blue;">warunans</span> </p>
      </div>
      On 1/31/2014 1:23 AM, MKNwebsolutions . wrote:<br>
    </div>
    <blockquote
cite="mid:CANmjbbOUo3+1Qk9NchSRDCOVC_Bc59hwHG2rhR2BOuVu7SSCjA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi all,
        <div><br>
        </div>
        <div>I stumbled upon an issue where I need to use object
          variables sessions to store cookies instead of on disk. &nbsp;I
          came up with a solution where I extract the sent cookies from
          the headers via regex into PHP object variables. &nbsp;I then
          resend those cookies using&nbsp;CURLOPT_COOKIE. &nbsp;</div>
        <div><br>
        </div>
        <div>This all works well, but not where there is header
          redirections (enabled via&nbsp;CURLOPT_FOLLOWLOCATION). &nbsp;I noticed
          cookies are not carried through this method when using this
          manual method. &nbsp;</div>
        <div>
          <br>
        </div>
        <div>So, I ended up disabling&nbsp;CURLOPT_FOLLOWLOCATION and
          manually connecting each redirection page. &nbsp;However, this
          method does / does not work on various sites. &nbsp;Some sites send
          multiple cookies with various flags at those header redirects
          - throwing off my solution. &nbsp;I assume that using the
          CURLOPT_COOKIEJAR method interprets the flags correctly.&nbsp;</div>
        <div><br>
        </div>
        <div>Anyone else stumble into this issue?</div>
        <div>
          <div>
            <div dir="ltr"><font face="'trebuchet ms', sans-serif"><b>
                  <div><font face="'trebuchet ms', sans-serif"><b><br>
                      </b></font></div>
                  <font>Michael Mikhjian</font><br>
                </b></font><b style="font-family:'trebuchet
                ms',sans-serif">Owner &middot;&nbsp;</b><font face="'trebuchet ms',
                sans-serif"><b>Senior Architect / Developer</b><br>
                <br>
                <a moz-do-not-send="true" href="http://mkn.us"
                  target="_blank">http://mkn.us</a><br>
              </font><font style="font-family:'trebuchet ms',sans-serif"
                size="1"><a moz-do-not-send="true"
                  href="http://www.linkedin.com/profile/view?id=7801327"
                  target="_blank">LinkedIn</a> &middot; <a
                  moz-do-not-send="true"
                  href="https://twitter.com/#%21/MKNwebSolutions"
                  target="_blank">Twitter</a> &middot; <a
                  moz-do-not-send="true"
                  href="https://www.facebook.com/MKNwebsolutions"
                  target="_blank">Facebook</a> &middot; <a
                  moz-do-not-send="true"
                  href="http://www.youtube.com/user/MKNwebsolutions"
                  target="_blank">Youtube</a><br>
              </font><br>
              <font style="font-family:'trebuchet ms',sans-serif"
                size="1">Mobile: <u>+1 248-289-0645</u>&nbsp;<span
                  style="font-family:'lucida
grande',tahoma,verdana,arial,sans-serif;font-size:10px;font-weight:bold;line-height:18px;background-color:rgb(255,255,255)">&middot;&nbsp;</span>Office:
                <u>+1 248-274-4643</u><br>
              </font><span style="font-family:'trebuchet
                ms',sans-serif;font-size:x-small">Troy, Michigan<br>
              </span><br>
              <img moz-do-not-send="true"
                src="http://mknwebsolutions.com/images/mlogo.png"><br>
              <div style="text-align:left;font-family:'trebuchet
                ms',sans-serif">
              </div>
              <font><font size="1"><i><br>
                    <div style="font-family:'trebuchet
                      ms',sans-serif;text-align:left"><i>Note: This
                        e-mail transmission, including any attachments,
                        is intended only for the named recipient(s) and
                        may contain information that is privileged,
                        confidential and/or exempt from disclosure under
                        applicable law. If you have received this
                        transmission in error, or are not the named
                        recipient(s), please notify MKN Web Solutions
                        immediately by return e-mail and permanently
                        delete this transmission, including any
                        attachments.</i></div>
                  </i></font></font></div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
<a class="moz-txt-link-freetext" href="http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php">http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>

--------------040408010802000604090804--

--===============1794319747==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

--===============1794319747==--