Created
October 9, 2019 07:05
-
-
Save abishekrsrikaanth/49ddecc1df2bedf576e0f53e66b54bf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Request | |
{ | |
private $is_last_session_id; | |
public function send($s_url, $data) | |
{ | |
$params = [ | |
'http' => [ | |
'method' => 'POST', | |
'content' => $data, | |
'header' => "Content-type: application/x-www-form-urlencoded", | |
], | |
]; | |
$ctx = stream_context_create($params); | |
ini_set('user_agent', 'PHP Client /5.2.00'); | |
$fp = fopen($s_url, 'rb', false, $ctx); | |
$response = stream_get_contents($fp); | |
$meta = stream_get_meta_data($fp); | |
foreach (array_keys($meta) as $h) { | |
$v = $meta[$h]; | |
if (is_array($v)) { | |
foreach (array_keys($v) as $hh) { | |
$vv = $v[$hh]; | |
if (is_string($vv) && substr_count($vv, 'JSESSIONID')) { | |
$this->is_last_session_id = substr($vv, strpos($vv, '=') + 1, 24); | |
} | |
} | |
} | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment