Curl Session Problem

Discussion in 'PHP' started by hip_hop_x, Sep 1, 2009.

  1. #1
    Hello!

    I tried to make a vbulletin forum poster, but i wasn't able to keep the user logged into the session, so maybe you might have a quick fix.

    function vbulletin_post($user,$pass,$url,$f,$title,$description){
    	global $_SERVER;
    	
    	//Login
    	$ch=curl_init();
    		curl_setopt($ch,CURLOPT_POST, true);
    		curl_setopt($ch,CURLOPT_POSTFIELDS, $post_fields);
    		curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    		curl_setopt($ch,CURLOPT_HEADER,false);
    		curl_setopt($ch,CURLOPT_COOKIESESSION, true);
    		curl_setopt($ch,CURLOPT_COOKIE,session_name().'='.session_id());
    		curl_setopt($ch,CURLOPT_COOKIEJAR,"tmpfile.tmp");
    		curl_setopt($ch,CURLOPT_COOKIEFILE,"tmpfile.tmp");
    		curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    		curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 1);
    		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30);
    	
    	$result = curl_exec($ch);
    	curl_close($ch);
    	echo $result;
    	}
    PHP:
     
    Last edited: Sep 1, 2009
    hip_hop_x, Sep 1, 2009 IP
  2. Auryx

    Auryx Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hmm i haven't looked in detail but all seems fine to me, maybe you missed a letter or something
     
    Auryx, Sep 1, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is the cookie jar file writable?
     
    premiumscripts, Sep 1, 2009 IP
  4. hip_hop_x

    hip_hop_x Active Member

    Messages:
    522
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #4
    thanks allot premiumscripts, it was a chmod problem
     
    hip_hop_x, Sep 1, 2009 IP