In Drupal I am logged in as a user. If I use my super cool drupal curl function:
function formtocart_graburl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
return $output;
}
to grab any url, it returns the content as if though I'm not logged in. How can I force CURL to think I am logged in as the user calling this function?
UPDATE
Assume the following:
- I am logged in at http://mydmomain.com/drupal
- I can access http://mydmomain.com/drupal/admin as I am an admin user
- When I am logged in, I try to grab the URL: http://mydmomain.com/drupal/admin, but it returns content that says I am not logged in.
- I would like curl to think I am logged in as the user I am logged into on Drupal
I assume the solution has something to do with grabbing the cookie or the sessions details and passing it to the curl function somehow?