cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Using cURL to store cookie session into variable / memory

From: MKNwebsolutions . <michael_at_mknwebsolutions.com>
Date: Thu, 30 Jan 2014 14:53:34 -0500

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 · **Senior Architect / Developer*

http://mkn.us
LinkedIn <http://www.linkedin.com/profile/view?id=7801327> ·
Twitter<https://twitter.com/#!/MKNwebSolutions
Facebook <https://www.facebook.com/MKNwebsolutions> ·
Youtube<http://www.youtube.com/user/MKNwebsolutions>

Mobile: *+1 248-289-0645* · 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. *

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2014-01-30