-
-
Save p810/5bba0bc5173671209298a34d0fb8c3ea 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 | |
$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); |
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 | |
// run the following to start a web server: | |
// php -S localhost:8181 | |
setcookie('abc123', 'Hello world!'); | |
header('Location: http://localhost:8181/read.php'); |
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 | |
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