N-Bomb(Nerd) Posted August 11, 2009 Share Posted August 11, 2009 I'm trying to add a cookiefile through in array -- like the following: curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie[$he][loc]); However, curl isn't registering it for some reason. I print "$cookie[$he][loc]" and it's to the direct path, and I've used is_string and it returns true.. so why can't I use this with curl? Is there a fix I can use to incorporate "$cookie[$he][loc]"? Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/ Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie[$he][loc]); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie[$he][loc]); Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/#findComment-895483 Share on other sites More sharing options...
N-Bomb(Nerd) Posted August 11, 2009 Author Share Posted August 11, 2009 Adding the cookiejar did nothing at all.. When I replace "$cookie[$he][loc]" with the file name for the cookiesfile it works.. I just can't seem to use the path from my array.. how can I use my array? Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/#findComment-895487 Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 Are your curl params in a function? If so is the array within the function scope? Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/#findComment-895490 Share on other sites More sharing options...
N-Bomb(Nerd) Posted August 11, 2009 Author Share Posted August 11, 2009 Are your curl params in a function? If so is the array within the function scope? Ah.. there's my problem. I have my array in my class construct().. how do I make it so a function within my class can access it from the construct? Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/#findComment-895499 Share on other sites More sharing options...
JonnoTheDev Posted August 11, 2009 Share Posted August 11, 2009 Set it as a member property <?php class foo { private $cookiePath; public function __construct($path) { $this->cookiePath = $path; } public function bar() { curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiePath); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiePath); } } $x = new foo($cookie[$he][loc]); $x->bar(); ?> Link to comment https://forums.phpfreaks.com/topic/169743-solved-curl-trouble/#findComment-895504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.