Solved

cURL Cookie Storage Question

Posted on 2006-07-10
4
1,630 Views
Last Modified: 2012-05-05
I have a script using cURL to login to a web site that uses cookies to store login information and grabs several bandwidth usage images (charts).

Now, this is the setting that I have in my script that sets the cookiejar file...
   curl_setopt($ci, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");

Since the login form gets submitted everytime I run the script, would it be possible to store the cookiejar in memory rather than in a file?  I'd rather store the cookies in memory than in a file.

Thanks,

Jeff
0
Comment
Question by:RWJDCom
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 17073415
Not sure if you can using any of the curl options.

If it actaully is the case that curl cannot suport this, then you can use stream_wrappers and use

curl_setopt($ci, CURLOPT_COOKIEJAR, "var://cookie");

This based on the streamwrapper for var:// as defined in http://php.net/manual/en/function.stream-wrapper-register.php

-r-
0
 
LVL 14

Accepted Solution

by:
ThG earned 125 total points
ID: 17073505
Why do you care about this? If the security is an issue, just create the empty file with fopen() and chmod() it to 0600, or use the umask() http://it.php.net/umask function.

If you are worried by performances, in linux there is a ram-based memory cache before filesystem (it's a module called vfs inside linux kernel), so if you create that file and unlink() it in a few seconds, it won't even be written to your hard drive.
0
 
LVL 8

Author Comment

by:RWJDCom
ID: 17079185
I'm not really concerned about security, I just don't want to have a file for the cookies...
0
 
LVL 8

Author Comment

by:RWJDCom
ID: 17095352
I'm going to check out that memory module.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP 5.6 and 7.x 4 41
How to extract database info from current month and year 7 36
show child records separated by commas 12 38
MySQL Persistent Connections 10 36
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question