Using cURL to store cookie session into variable / memory
"MKNwebsolutions ." <[email protected]> Thu, 30 Jan 2014 14:53:34 -0500
| Newsgroups | gmane.comp.web.curl.php |
|---|---|
| Message-ID | <CANmjbbOUo3+1Qk9NchSRDCOVC_Bc59hwHG2rhR2BOuVu7SSCjA@mail.gmail.com> |
--===============1745742733== Content-Type: multipart/alternative; boundary=001a11c128a8d0252a04f1356a58 --001a11c128a8d0252a04f1356a58 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 the 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/#!/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. * --001a11c128a8d0252a04f1356a58 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <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 he= aders via regex into PHP object variables. =A0I then resend those cookies u= sing=A0CURLOPT_COOKIE. =A0</div> <div><br></div><div>This all works well, but not where there is header redi= rections (enabled via=A0CURLOPT_FOLLOWLOCATION). =A0I noticed cookies are n= ot carried through this method when using this manual method. =A0</div><div= > <br> </div><div>So, I ended up disabling=A0CURLOPT_FOLLOWLOCATION and manually c= onnecting each redirection page. =A0However, this method does / does not wo= rk on various sites. =A0Some sites send multiple cookies with various flags= at those header redirects - throwing off my solution. =A0I assume that usi= ng the CURLOPT_COOKIEJAR method interprets the flags correctly.=A0</div> <div><br></div><div>Anyone else stumble into this issue?</div><div><div><di= v dir=3D"ltr"><font face=3D"'trebuchet ms', sans-serif"><b><div><fo= nt face=3D"'trebuchet ms', sans-serif"><b><br></b></font></div><fon= t>Michael Mikhjian</font><br> </b></font><b style=3D"font-family:'trebuchet ms',sans-serif">Owner= =B7=A0</b><font face=3D"'trebuchet ms', 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:'trebuchet ms',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:'trebuchet ms',san= s-serif">Mobile: <u>+1 248-289-0645</u>=A0<span style=3D"font-family:'l= ucida grande',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:'trebuchet ms',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:'t= rebuchet ms',sans-serif"> </div><font><font size=3D"1"><i><br><div style=3D"font-family:'trebuche= t ms',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> </div></div> --001a11c128a8d0252a04f1356a58-- --===============1745742733== 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 --===============1745742733==--