note 87112 modified in function.curl-setopt by danbrown

From: Date: Sun, 17 May 2009 17:16:06 +0000
Subject: note 87112 modified in function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154961@lists.php.net to get a copy of this message
Passing in PHP's $_SESSION into your cURL call: <?php session_start(); $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/'; session_write_close(); $curl_handle = curl_init('enter_external_url_here'); curl_setopt( $curl_handle, CURLOPT_COOKIE, $strCookie ); curl_exec($curl_handle); curl_close($curl_handle); ?> This worked great for me. I was calling pages from the same server and needed to keep the $_SESSION variables. This passes them over. If you want to test, just print_r($_SESSION); Enjoy! --was-- Passing in PHP's $_SESSION into your cURL call: session_start(); $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/'; session_write_close(); $curl_handle = curl_init('enter_external_url_here'); curl_setopt( $curl_handle, CURLOPT_COOKIE, $strCookie ); curl_exec($curl_handle); curl_close($curl_handle); This worked great for me. I was calling pages from the same server and needed to keep the $_SESSION variables. This passes them over. If you want to test, just print_r($_SESSION); Enjoy! http://php.net/manual/en/function.curl-setopt.php

« previous php.notes (#154961) next »