How to create DF session for Web access


#1

Hi

How I can create DF session using my own custom php file

I have this https://df.mydom.com/umar.php

<?php

        $email_id = "umar@mydomain.com";
        $password = "mypassword";
        $api_key = "6498a8ad1beb9d84d6d";

        $data = array("email" => $email_id, "password" => $password);
        $data_string = json_encode($data);

       // my user is admin of DF that's why calling /admin/session

        $ch = curl_init('https://df.mydom.com/api/v2/system/admin/session');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, 1);

        $result = curl_exec($ch);
        $response = json_decode($result);
        $session_token = $response->session_id;
        curl_close($ch);

        if($session_token){
                header("Location: https://df.mydom.com/?api_key=$api_key&session_token=$session_token");
        }
        else {
                echo 'Error';
        }

?>

The session was created successfully, but after the redirect I still got DF login page. Would you please help me how I can create Web browser session.

Regards