Hello i want to create login sigle sign on (sso)
i have to ip 2 ip address
#1 http://192.168.10.203:2119/ for login (home)
#2 http://192.168.10.203:8007/ for access application (apps)
i have 2 database
db_home
db_apps
when i create login in home and set curl to file apps
file : proses_login.php in home
<?php
include "con_db_home.php";
$username = $_POST['username'];
$pwd = hash('sha512', $_POST['password']);
$sql = mysqli_query($con,"SELECT * FROM app_user WHERE username='".$username."' and password='".$pwd."' and status='1'");
$result = mysqli_fetch_object($sql);
$_SESSION['id_user'] = $result->id_user;
$_SESSION['username'] = $result->username;
$_SESSION['status'] = $result->status;
$_SESSION['role'] = $result->role;
session_start();
if($result->username!=""){
$_SESSION['id_user'] = $result->id_user;
$_SESSION['username'] = $result->username;
$_SESSION['status'] = $result->status;
$_SESSION['role'] = $result->role;
$target_site = "http://192.168.10.203:8007/connect_curl.php";
$myvars = 'id_sso='.$result->id_user;
$ch = curl_init($target_site);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
curl_close();
header('Location: .');
return;
}
else {
echo "<script language='JavaScript'> alert ('Wrong Username / Password'); </script>
<script language='JavaScript'>document.location='.'</script>";
}
?>
file : connect_curl.php in apps
<?php
ob_start();
session_start();
include("con_db_apps.php");
$id_sso = $_REQUEST['id_sso'];
if($id_sso==""){
header('Location: .');
}
else {
$data_us = "select * from tbl_user where user_id_sso='".$id_sso."' ";
$resultdb= $f->get_last_record($data_us);
foreach($resultdb as $key=>$val) $$key=$val;
setcookie("login_session","$id_hash");
setcookie("login_nip","$nip");
setcookie("login_username","$username");
setcookie("login_name","$first_name $last_name");
setcookie("login_fua","$fua_name");
else {
session_destroy();
header('Location: .');
}
}
i'm confused because cookie not created when i'm using curl. Because i cannot login to apps. but when bypass like this http://192.168.10.203:8007/connect_curl.php?id_sso=3 this cookie created and i can login. So how to create cookie when using curl ?
Please help me thank's