I have an issue on Laravel 5.5. I have a web application that acts as a gateway. My partner can request to my gateway via cURL or HTTP.
But when I try to request validate master data and credential in postman and get the session back by the postman, I can get it back.
My Sample Testing by using fix session key:
TestingController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Hash;
use Session;
class TestingController extends Controller
{
public function test1() {
$testing = "Testing";
Session::put("ABC", $testing);
return "Key: ABC, Value: $testing";
}
public function test2() {
$testing = Session::get("ABC");
return "Key: ABC, Value: $testing";
}
}
}
web.php (route)
Route::post('/test1', 'TestingController@test1');
Route::get('/test2', 'TestingController@test2');
Sample request from php
<?php
$authenticate = "http://localhost/test1";
$redirect = "http://localhost/test2";
$ref_gen = date("Ymdhisa");
if($_POST['submit']) {
$param = array(
'username'=> 'testing',
'secrete' => '85a731b9d40388ad0a998d84e7e9de958c2',
'order_referenceno' => $ref_gen,
);
$content = json_encode($param);
$curl = curl_init($authenticate);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type:application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($curl);
var_dump("response:".$response);
if ($response === FALSE) {
echo "cURL Error: " . curl_error($curl);
} else {
header("Location: ".$redirect."?session=$response");
}
}
?>