Solved

cURL Cookie Storage Question

Posted on 2006-07-10
4
1,597 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now