I am trying to access an admin routed url from a frontend routed URL using curl. I do the following:

            $ch = curl_init();
            curl_setopt ($ch, CURLOPT_URL, 'http://site.com/index.php/admin/mycache/verify/');
            curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
            curl_setopt ($ch, CURLOPT_COOKIE, $_COOKIE['adminhtml']);
            $Verify = curl_exec($ch);
            echo "V: $Verify";

The idea here is that I want that url to return a 1 if the user is logged into the admin part of my site, and anything else otherwise. When I do the above though, even though the adminhtml cookie is set, curl never gets the data from that URL. Can someone explain why and/or how to fix that?

1 Answer 1


You can try following -

$sesId = isset($_COOKIE['adminhtml']) ? $_COOKIE['adminhtml'] : false ;
$session = false;
    $session = Mage::getSingleton('core/resource_session')->read($sesId);
$loggedIn = false;
        $loggedIn = true;

This will be true if admin logged in and false if not. Hope this will help you.

  • Does "Mage::getSingleton('core/resource_session')->read($sesId);" only return a session if there is a real session and not just a spoofed cookie?
    – user2045
    Aug 30, 2013 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.