amalosoul Posted April 26, 2010 Share Posted April 26, 2010 I have two pages p1.php and p2.php and each of them sets a session variable, one called: 'olive' and the other one: 'bananas'. p1.php (sets 'olive') calls through cURL p2.php (sets 'bananas'). How come each time I change bananas I have to reload the page twice in order to show $_SESSION['bananas'] correctly? (it has nothing to do with cache since I used multiple browsers and the same thing happens) p2.php session_start(); $_SESSION['bananas'] = 2; p1.php function get_web_page( $url, $var ) { $options = array( CURLOPT_POST => 1, //CURLOPT_POSTFIELDS => POSTVARS, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_HEADER => 0, // RETURN HTTP HEADERS CURLOPT_COOKIE => "PHPSESSID=".$var, CURLOPT_TIMEOUT => 3, //timeout on response CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 3, // timeout on connect CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } session_start(); $_SESSION['olive'] = 5; session_write_close(); $vect = (get_web_page("http://localhost/testarea/p2.php",session_id())); echo $_SESSION['olive']." ".$_SESSION['bananas']; Thank you in anticipation! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 26, 2010 Share Posted April 26, 2010 Try putting session_start at the top of the file. Quote Link to comment Share on other sites More sharing options...
amalosoul Posted April 26, 2010 Author Share Posted April 26, 2010 Unfortunately, I get the same result. Thank you for your patience. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 26, 2010 Share Posted April 26, 2010 I have a question, is there a reason to use cURL for that? You couldn't just include or require the page? Quote Link to comment Share on other sites More sharing options...
amalosoul Posted April 26, 2010 Author Share Posted April 26, 2010 This is just for testing, I would've included it if I could. At first I didn't even understand the problem. Now I found it but it is simply illogical. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.