I know that you said that you do not want to use cookies because they are unsafe. In the following solution, the client session cookie is “redirected” to the second request. Sending a cookie to the local computer should not create security flaws.
You can transfer the session cookie from the client browser to a new, server request (thanks Ben for pointing out session_name).
$curl_cookies = session_name() . '=' . session_id() . '; path=/';
curl_setopt($ch, CURLOPT_COOKIE, $curl_cookies);
For simplicity, I only pass the cookie PHPSESSID (I also assume this is your session cookie key).
source
share