tags:

views:

17

answers:

1

Hello Guys,

In the old way in our website, when users clicks “logout” button. It runs a post form function; which will pass parameters (logout, sn) to external sites to execute “logout” function. Like:

I do not want the users jump to the external site, therefore, i use curl to post data. (because we are in different domain, i guess Ajax request doesnot work )

Post the same data to execute logout function in external site.

// create cURL resource
        $URL = "http://bswi.development.intra.local/";

        //Initl curl
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $URL);  // Load in the destination URL
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //Normal HTTP request, not SSL
        curl_setopt($ch, CURLOPT_POSTFIELDS, "logout=1"); 

       // receive server response ...
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        curl_exec ($ch);
        echo $content;
        curl_close ($ch);

Do u think i am going in the right direction?

A: 

That might work, but if you want to use Basic HTTP Auth, you also need to provide credentials (name + password).

Daniel Stenberg