What is the most standardized method of utilizing the CURL functions
in PHP (version 4.3.2) to be able to retrieve the contents of a remote
URL that happens to be dependent upon $_SESSION for its content
display?
I've tried the following class methods for display and I have most
everything working until I get to a URL that requires $_SESSION:
[PHP]
class Timer extends View {
function Timer() {}
function &setCookieCurlSetOpt(&$ch) { // STATIC VOID METHOD
if ($this->cookieName) {
$qs = '&' . $this->cookieName . '=';
if (is_array($_COOKIE[$this->cookieName]) ||
is_object($_COOKIE[$this->cookieName])) {
$qs .= urlencode(serialize($_COOKIE[$this->cookieName]));
} else {
$qs .= urlencode($_COOKIE[$this->cookieName]);
}
} elseif (@sizeof(array_values($_COOKIE)) > 0) {
foreach ($_COOKIE as $key => $val) if (is_array($val) ||
is_object($val)) $qs .= "&$key=" . urlencode(serialize($val)); else
$qs .= "&$key=" . urlencode($val);
}
if ($qs) curl_setopt($ch, CURLOPT_COOKIE, substr($qs, 1,
strlen($qs)));
}
function &displayHTML($url = '') { // STATIC HTML
STRING METHOD
global $projectFolderName, $PHPSESSID;
if (is_object($this) && !$this->getURL() && $url)
$this->setURL($url);
if (is_object($this)) $url = $this->getURL();
if ($url && ini_get('allow_url_fopen')) {
$url = $this->configureURL($url);
// grab URL and pass it to the browser
$ch = curl_init();
$this->setCookieCurlSetOpt($ch);
//$this->setPOSTCurlSetOpt($ch);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
$this->setTime($this->startTime); // SET START TIME
ob_start();
curl_exec($ch);
$html = ob_get_contents();
ob_end_clean();
$timer = $this->setTime($timer);
// close curl resource, and free up system resources
curl_close($ch);
$html = preg_replace('/(.*<body[^>]*>)/i', '$1<p><b>' .
($timer - $this->startTime) . " seconds to run URL: \"$url\"</b>",
$html);
}
return $html;
}
}
[/PHP]
utilizing this class in a script: timer.php:
<?php
session_cache_limiter();
session_start();
echo '<P>My session from timer.php is: '; print_r($_SESSION);
....
?>
I see my $_SESSION variable.
Now, if timer.php instantiates a Timer object that uses the URL
parameter of "http://www.myphpwebsite.com/index.php" it will scrape
that site. The site's script: index.php, also has the following:
<?php
session_cache_limiter();
session_start();
echo '<P>My session from index.php is: '; print_r($_SESSION);
....
?>
Now here's the kicker: If I call index.php directly, everything's
fine, $_SESSION exists, all is fine. If I call index.php as a scrape
via timer.php, then timer.php displays $_SESSION but index.php's
scrape shows nothing, just an empty array instead of $_SESSION with
its contents:
[timer.php]
My session from timer.php is: Array([lots of stuff])
My session from index.php is: Array()
[/timer.php]
Is there something about autoglobals and CURL in general, or is there
something specific about $_SESSION and CURL, or perhaps
session_start() and CURL? I am not sure what I can do about this
dilemma as it means my Timer object will not accurately show how long
it took for index.php to evaluate and download since the returned
content is wrong due to the seeming nonexistence of $_SESSION all of a
sudden ($_SESSION is not changed at any time during the run of
timer.php)
I hope this is detailed enough to provide a clear picture of exactly
what is going on and will allow for someone to give me further insight
into the workings of CURL with $_SESSION or autoglobals in general.
Thanx
Phil 0 2468 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Haluk Durmus |
last post by:
Hello
I checked out openssl,mm,apr,apr-util,apache 2,curl,libxml and php
from cvs.
php couse an ERROR
I did the following steps:
|
by: Roman |
last post by:
Hi,
I've installed .net on my server and since then I'm loosing my
sessions from my (old) asp.
e.g.: Session("test") works on the same page, but if the page is
changed the whole session is registered new and sothe stored data is
lost.
(my session timeout is default on 20 min / bevore my .net installation
|
by: Marek |
last post by:
Hi,
I have the following session problem:
I've created simple login/logout form to prevent unknown users from
accessing my private web site part and It is not working on the www server.
It seems that the session lasts very shortly - sometimes couple of minutes
and sometimes it is even impossible to login. The whole application is
working...
|
by: Sabari |
last post by:
Hi,
In our application we face a session problem.Its kinda strange as
well.We have our session timeout in web.config file to 240 minutes.It
works fine in our intranet.When we moved the project to the clients
intranet the session gets timed out in 20 mins.We checked with the
web.config and all the settings are correct.Is there any other factor...
|
by: caldera |
last post by:
Hello,
We have a session problem. A dataset is put into a session and call this
session value later. When we run this web page in http://localhost it works.
But server has a specific name like http://aaa_bbb_ccc . When we try to run
this code by writting this name the session parameters doesn't stored and
give an error. When we writting ip...
| |
by: alan |
last post by:
Hi, i have some problem in asp.net session problem
in page_load ->
i have
Label1.text = Session("a")
in DataGrid1_sortCommand ->
i have
Session("a") = e.sortExpression
|
by: sri |
last post by:
Hi, I have Login page (login.aspx") and after entering into inbox by giving valid userid and password the session item is userid and password. In inbox page ("inbox.aspx") i have logoff button and the code in the button is sessions are null and it redirects to login page. Before clicking the logof button i copy the inbox url. when i get the login...
|
by: lookee |
last post by:
Hello all,
I have simple PHP application that on one page strarts session and
write some information to it. On another page program tryes to fetch
information from a third page using cURL. On that third page program
needs to retrive information that were written to the session and use
them. Problem is that when I call the third page and call...
|
by: deepsfriend4u |
last post by:
Hello,
i have one application in that i use session .
problem is,
same code and session data use work successful in Firefox but not work in Internet Explore.
Thanks & Regards
Deepak
|
by: Kong Chun Ho |
last post by:
Hi all,
I have a php session problem when i echo a session_id, it return nothing!
<?php if(!session_start()) { exit(); }else{ ob_start(); session_start(); echo session_id(); echo SID; ob_end_clean(); }?>
// html code...
nothing returned!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |