$_SESSION['u_id'] //check if asa id session is set if true continue if not, redirect to data con login exit; //if session id exist generate and send random token to data con account using "data con put token web service" //if data con recognize this token, data con will get the owner of token and use it to login without putting uname & pw //data con will delete the token for security purpose ob_start(); include 'core/init.php'; if($_SESSION['u_id']){ $token = generateRandomString(64); $asa_session_id = addslashes($_SESSION['u_id']); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://connect.autohub.ph/api/employee/put_token.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('apiKey' => '52658734657484365783' ,'token' => $token ,'id' => $asa_session_id))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close ($ch); } header('location: http://connect.autohub.ph/api/employee/login.php?token='.$token); function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } ?>