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

"MKNwebsolutions ." <[email protected]> Thu, 30 Jan 2014 21:23:46 -0500
Newsgroups gmane.comp.web.curl.php
Message-ID <CANmjbbNSf69E+AAkGNRb18gw47HZGL0=ctaQEehhBw2JBobUvQ@mail.gmail.com>
--===============0383672735==
Content-Type: multipart/alternative; boundary=001a11c128a84e9d9004f13ade4d

--001a11c128a84e9d9004f13ade4d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thanks Waruna.

You're correct, the method does work.  I solved it shortly afterwards, I
tried to remove my post from here but it seems it did not go through.

Solution @
http://stackoverflow.com/questions/21442976/php-using-curl-to-store-cookie-=
session-into-variable-memory



*Michael Mikhjian **Owner =B7 **Senior Architect / Developer*

http://mkn.us
LinkedIn <http://www.linkedin.com/profile/view?id=3D7801327> =B7
Twitter<https://twitter.com/#!/MKNwebSolutions>=B7
Facebook <https://www.facebook.com/MKNwebsolutions> =B7
Youtube<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 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. *


On Thu, Jan 30, 2014 at 9:21 PM, Waruna Geekiyanage <[email protected]>wr=
ote:

>  Hi Michael Mikhjian,
>
> This method worked for me perfectly when all the cookes from redirects
> 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] <[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
> to store cookies instead of on disk.  I came up with a solution where I
> extract the sent cookies from the headers via regex into PHP object
> variables.  I then resend those cookies using CURLOPT_COOKIE.
>
>  This all works well, but not where there is header redirections (enabled
> via CURLOPT_FOLLOWLOCATION).  I noticed cookies are not carried through
> this method when using this manual method.
>
>  So, I ended up disabling CURLOPT_FOLLOWLOCATION and manually connecting
> each redirection page.  However, this method does / does not work on
> various sites.  Some sites send multiple cookies with various flags at
> those header redirects - throwing off my solution.  I assume that using t=
he
> CURLOPT_COOKIEJAR method interprets the flags 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 Twitter<=
https://twitter.com/#%21/MKNwebSolutions>=B7
> Facebook <https://www.facebook.com/MKNwebsolutions> =B7 Youtube<http://ww=
w.youtube.com/user/MKNwebsolutions>
>
> Mobile: *+1 248-289-0645 <%2B1%20248-289-0645>* =B7 Office: *+1
> 248-274-4643 <%2B1%20248-274-4643>*
> Troy, Michigan
>
>
>
> * 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 name=
d
> recipient(s), please notify MKN Web Solutions immediately by return e-mai=
l
> and permanently delete this transmission, including any attachments. *
>
>
> _______________________________________________http://cool.haxx.se/cgi-bi=
n/mailman/listinfo/curl-and-php
>
>
>

--001a11c128a84e9d9004f13ade4d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks Waruna.<div><br></div><div>You&#39;re correct, the =
method does work. =A0I solved it shortly afterwards, I tried to remove my p=
ost from here but it seems it did not go through.</div><div><br></div><div>=
Solution @=A0</div>

<div><a href=3D"http://stackoverflow.com/questions/21442976/php-using-curl-=
to-store-cookie-session-into-variable-memory">http://stackoverflow.com/ques=
tions/21442976/php-using-curl-to-store-cookie-session-into-variable-memory<=
/a><br>

</div></div><div class=3D"gmail_extra"><br clear=3D"all"><div><div dir=3D"l=
tr"><font face=3D"&#39;trebuchet ms&#39;, sans-serif"><b><div><font face=3D=
"&#39;trebuchet ms&#39;, sans-serif"><b><br></b></font></div><font>Michael =
Mikhjian</font><br>

</b></font><b style=3D"font-family:&#39;trebuchet ms&#39;,sans-serif">Owner=
 =B7=A0</b><font face=3D"&#39;trebuchet ms&#39;, sans-serif"><b>Senior Arch=
itect / Developer</b><br><br><a href=3D"http://mkn.us" target=3D"_blank">ht=
tp://mkn.us</a><br>

</font><font size=3D"1" style=3D"font-family:&#39;trebuchet ms&#39;,sans-se=
rif"><a href=3D"http://www.linkedin.com/profile/view?id=3D7801327" target=
=3D"_blank">LinkedIn</a> =B7 <a href=3D"https://twitter.com/#!/MKNwebSoluti=
ons" target=3D"_blank">Twitter</a> =B7 <a href=3D"https://www.facebook.com/=
MKNwebsolutions" target=3D"_blank">Facebook</a> =B7 <a href=3D"http://www.y=
outube.com/user/MKNwebsolutions" target=3D"_blank">Youtube</a><br>

</font><br><font size=3D"1" style=3D"font-family:&#39;trebuchet ms&#39;,san=
s-serif">Mobile: <u>+1 248-289-0645</u>=A0<span style=3D"font-family:&#39;l=
ucida grande&#39;,tahoma,verdana,arial,sans-serif;font-size:10px;font-weigh=
t:bold;line-height:18px;background-color:rgb(255,255,255)">=B7=A0</span>Off=
ice: <u>+1 248-274-4643</u><br>

</font><span style=3D"font-family:&#39;trebuchet ms&#39;,sans-serif;font-si=
ze:x-small">Troy, Michigan<br></span><br><img src=3D"http://mknwebsolutions=
.com/images/mlogo.png"><br><div style=3D"text-align:left;font-family:&#39;t=
rebuchet ms&#39;,sans-serif">

</div><font><font size=3D"1"><i><br><div style=3D"font-family:&#39;trebuche=
t ms&#39;,sans-serif;text-align:left"><i>Note: This e-mail transmission, in=
cluding any attachments, is intended only for the named recipient(s) and ma=
y contain information that is privileged, confidential and/or exempt from d=
isclosure under applicable law. If you have received this transmission in e=
rror, or are not the named recipient(s), please notify MKN Web Solutions im=
mediately by return e-mail and permanently delete this transmission, includ=
ing any attachments.</i></div>

</i></font></font></div></div>
<br><br><div class=3D"gmail_quote">On Thu, Jan 30, 2014 at 9:21 PM, Waruna =
Geekiyanage <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" ta=
rget=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
adding-left:1ex">


 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>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>
       =20
        <p class=3D"MsoNormal"> <span style=3D"font-size:10pt;font-family:&=
#39;Arial&#39;,&#39;sans-serif&#39;;color:rgb(31,73,125)">Thank
            You,<br>
            Waruna Geekiyanage</span> </p>
        <p class=3D"MsoNormal"><span style=3D"font-size:12pt;color:rgb(31,7=
3,125)">M:=A0<a href=3D"tel:%2B94%2071%204168164" value=3D"+94714168164" ta=
rget=3D"_blank">+94 71 4168164</a></span> <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125);font-family:&#=
39;Times New Roman&#39;,&#39;serif&#39;"> E:</span> <a href=3D"mailto:warun=
[email protected]" target=3D"_blank"> <span style=3D"color:blue;font-family:&#3=
9;Calibri&#39;,&#39;sans-serif&#39;">[email protected]</span></a>
          <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125)">MSN:</span>
          <span style=3D"font-family:&#39;Calibri&#39;,&#39;sans-serif&#39;=
;color:blue"><a href=3D"mailto:[email protected]" target=3D"_blank">waru=
[email protected]</a></span> <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125)">GTalk:</span>
          <span style=3D"font-family:&#39;Calibri&#39;,&#39;sans-serif&#39;=
;color:blue">waruna.ns</span> <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125)">ICQ:</span>
          <span style=3D"font-family:&#39;Calibri&#39;,&#39;sans-serif&#39;=
;color:blue">225184383</span> <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125)">Yahoo:</span>
          <span style=3D"font-family:&#39;Calibri&#39;,&#39;sans-serif&#39;=
;color:blue">warunans</span> <br>
          <span style=3D"font-size:12pt;color:rgb(31,73,125)">Skype:</span>
          <span style=3D"font-family:&#39;Calibri&#39;,&#39;sans-serif&#39;=
;color:blue">warunans</span> </p>
      </div><div><div class=3D"h5">
      On 1/31/2014 1:23 AM, MKNwebsolutions . wrote:<br>
    </div></div></div>
    <blockquote type=3D"cite"><div><div class=3D"h5">
      <div dir=3D"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. =A0I
          came up with a solution where I extract the sent cookies from
          the headers via regex into PHP object variables. =A0I then
          resend those cookies using=A0CURLOPT_COOKIE. =A0</div>
        <div><br>
        </div>
        <div>This all works well, but not where there is header
          redirections (enabled via=A0CURLOPT_FOLLOWLOCATION). =A0I noticed
          cookies are not carried through this method when using this
          manual method. =A0</div>
        <div>
          <br>
        </div>
        <div>So, I ended up disabling=A0CURLOPT_FOLLOWLOCATION and
          manually connecting each redirection page. =A0However, this
          method does / does not work on various sites. =A0Some sites send
          multiple cookies with various flags at those header redirects
          - throwing off my solution. =A0I assume that using the
          CURLOPT_COOKIEJAR method interprets the flags correctly.=A0</div>
        <div><br>
        </div>
        <div>Anyone else stumble into this issue?</div>
        <div>
          <div>
            <div dir=3D"ltr"><font face=3D"&#39;trebuchet ms&#39;, sans-ser=
if"><b>
                  <div><font face=3D"&#39;trebuchet ms&#39;, sans-serif"><b=
><br>
                      </b></font></div>
                  <font>Michael Mikhjian</font><br>
                </b></font><b>Owner =B7=A0</b><font face=3D"&#39;trebuchet =
ms&#39;,
                sans-serif"><b>Senior Architect / Developer</b><br>
                <br>
                <a href=3D"http://mkn.us" target=3D"_blank">http://mkn.us</=
a><br>
              </font><font style=3D"font-family:&#39;trebuchet ms&#39;,sans=
-serif" size=3D"1"><a href=3D"http://www.linkedin.com/profile/view?id=3D780=
1327" target=3D"_blank">LinkedIn</a> =B7 <a href=3D"https://twitter.com/#%2=
1/MKNwebSolutions" target=3D"_blank">Twitter</a> =B7 <a href=3D"https://www=
.facebook.com/MKNwebsolutions" target=3D"_blank">Facebook</a> =B7 <a href=
=3D"http://www.youtube.com/user/MKNwebsolutions" target=3D"_blank">Youtube<=
/a><br>


              </font><br>
              <font style=3D"font-family:&#39;trebuchet ms&#39;,sans-serif"=
 size=3D"1">Mobile: <u><a href=3D"tel:%2B1%20248-289-0645" value=3D"+124828=
90645" target=3D"_blank">+1 248-289-0645</a></u>=A0<span>=B7=A0</span>Offic=
e:
                <u><a href=3D"tel:%2B1%20248-274-4643" value=3D"+1248274464=
3" target=3D"_blank">+1 248-274-4643</a></u><br>
              </font><span>Troy, Michigan<br>
              </span><br>
              <img src=3D"http://mknwebsolutions.com/images/mlogo.png"><br>
              <div>
              </div>
              <font><font size=3D"1"><i><br>
                    <div><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></fieldset>
      <br>
      </div></div><pre>_______________________________________________
<a href=3D"http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php" targe=
t=3D"_blank">http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></div>

--001a11c128a84e9d9004f13ade4d--

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

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

--===============0383672735==--