您好我想创建登录sigle登录(sso)
我必须ip 2 ip地址
#1 http://192.168.10.203:2119/用于登录(主页)
#2 http://192.168.10.203:8007/用于访问应用程序(应用)
我有2个数据库
db_home
db_apps
当我在主页中创建登录并将curl设置为文件应用时
在主页 中文件: proses_login.php
function changeUrl(title, url) {
if (typeof (history.pushState) != "undefined") {
var obj = {Page: title, Url: url};
history.pushState(obj, obj.Page, obj.Url);
}
}
应用 中的文件: connect_curl.php
<?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>";
}
?>
我很困惑,因为我在使用curl时没有创建cookie。因为我无法登录应用程序。但是当这样绕过时 http://192.168.10.203:8007/connect_curl.php?id_sso=3 这个cookie已创建,我可以登录。那么如何在使用curl时创建cookie?
请帮助我谢谢