persist cookie data without using CURLOPT_COOKIEJAR?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
scanf
Forum Newbie
Posts: 3
Joined: Thu Sep 30, 2010 5:12 pm

persist cookie data without using CURLOPT_COOKIEJAR?

Post by scanf »

i'm using php as a middle layer to hit a web api for an ajax front end. this web api sets and reads cookies upon each call after a successful authenticated login, so i needed a way to simulate this since this request isn't being made from a browser, but a web server.

the problem here is the use of curl's CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE to satisfy that need. these read and write to a server-side text file which in my situation will be accessed hundreds to thousands of times a minute or more on a high-traffic site.

google hasn't helped me, but i'm worried that this may not be efficient enough for an enterprise-level web application. can anyone comment on this or provide their own personal experience on the matter.

one obvious options are passing the data to the client, which will pass it back for subsequent requests and then injected into the header data manually. but this is dirty, and also a bit chatty for all the subsequent ajax calls. any better ideas? i'm better versed in other server-side languages/technologies still, so there may be something out of the box i'm just unaware of. thanks.
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: persist cookie data without using CURLOPT_COOKIEJAR?

Post by DigitalMind »

Code: Select all

curl_setopt($c, CURLOPT_COOKIE, 'city=' . $cities[$pid_index][0]);
scanf
Forum Newbie
Posts: 3
Joined: Thu Sep 30, 2010 5:12 pm

Re: persist cookie data without using CURLOPT_COOKIEJAR?

Post by scanf »

thanks, but that's not really what I'm after.

is it possible to read/intercept what would be pushed to the cookiejar? i don't like the idea of manually parsing the headers for this if there's a more direct way.

basically, i could just dump this data in a client-side cookie and then pass them back in using CURLOPT_COOKIE.
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: persist cookie data without using CURLOPT_COOKIEJAR?

Post by DigitalMind »

scanf wrote:is it possible to read/intercept what would be pushed to the cookiejar?
No
Please correct me if I'm wrong. I had same problem long time ago. The only solution I found is to parse headers.
scanf
Forum Newbie
Posts: 3
Joined: Thu Sep 30, 2010 5:12 pm

Re: persist cookie data without using CURLOPT_COOKIEJAR?

Post by scanf »

DigitalMind wrote: No
Please correct me if I'm wrong. I had same problem long time ago. The only solution I found is to parse headers.
yeah, i kinda figured that and already started down that path. thanks.
Post Reply