Skip to content

Instantly share code, notes, and snippets.

@p810

p810/client.php Secret

Created July 15, 2020 14:46
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 p810/5bba0bc5173671209298a34d0fb8c3ea to your computer and use it in GitHub Desktop.
Save p810/5bba0bc5173671209298a34d0fb8c3ea to your computer and use it in GitHub Desktop.
<?php
$c = curl_init();
curl_setopt_array($c, [
CURLOPT_URL => 'http://localhost:8181/index.php',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_COOKIEJAR => 'cookie.txt',
CURLOPT_COOKIEFILE => 'cookie.txt',
CURLOPT_HTTPHEADER => [
'User-Agent: Test-Client',
'Accept-Encoding: gzip, deflate, br',
'Accept-Language: en-US,en;q=0.9',
],
CURLOPT_FOLLOWLOCATION => true,
]);
file_put_contents('output.log', curl_exec($c));
curl_close($c);
<?php
// run the following to start a web server:
// php -S localhost:8181
setcookie('abc123', 'Hello world!');
header('Location: http://localhost:8181/read.php');
<?php
if (! isset($_COOKIE['abc123'])) {
http_response_code(400);
exit('Cookie was not set');
}
echo $_COOKIE['abc123'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment