Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $apiURL = "https://portalqa.kyrioscloud.com/users/sign_in?format=json";
- $apiusername = filter_var($_SESSION['username']);
- $apipassword = filter_var($_SESSION['password']);
- $jsoncredentials = "{\"user\":" . "{\"email\":\"" . $apiusername . "\",\"password\":\"" . $apipassword . "\"}}";
- $obj = (object) [
- 'user' => ['email' => $apiusername, 'password' => $apipassword]
- ];
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'POST',
- 'content' => http_build_query($obj)
- )
- );
- $context = stream_context_create($options);
- $result = get_headers($apiURL, false, $context);
- if (strpos(json_encode($result), 'HTTP/1.1 401 Unauthorized') !== false) { /* Handle error */
- session_destroy();
- header('Location: ../../public_html/login.php');
- } else {
- $temp = explode(" ", $result[10]);
- $temp = explode("=", $temp[1]);
- $token = explode(";", $temp[1]);
- $temp = explode(" ", $result[11]);
- $temp = explode("=", $temp[1]);
- $sessionID = explode(";", $temp[1]);
- $_SESSION["XSRF-TOKEN"] = $token[0];
- $_SESSION["_session_id"] = $sessionID[0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement