Answer the question
In order to leave comments, you need to log in
How to resume the session in another script, which I access via curl?
Hello.
It is necessary to somehow resume the session in another script, which I access via curl.
There are two scripts on the server - 1.php and 2.php
In 1.php the following code:
session_start();
$_SESSION[0] = '123';
$url = 'http://сайт/2.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
$html = curl_exec($ch);
echo $html;
session_start();
print_r($_SESSION);
Fatal error: Maximum execution time of 30 seconds exceeded in ... on line 21
Answer the question
In order to leave comments, you need to log in
Solution: You need to close the entry to the session before getting data from it in another script.session_write_close();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question