Skip to content

Instantly share code, notes, and snippets.

@abishekrsrikaanth
Created October 9, 2019 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abishekrsrikaanth/49ddecc1df2bedf576e0f53e66b54bf9 to your computer and use it in GitHub Desktop.
Save abishekrsrikaanth/49ddecc1df2bedf576e0f53e66b54bf9 to your computer and use it in GitHub Desktop.
<?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