Skip to content

Instantly share code, notes, and snippets.

@Goldenflamer
Created October 26, 2019 20:43
Show Gist options
  • Save Goldenflamer/d903bc015c0f81bddfb4ac8089ab4884 to your computer and use it in GitHub Desktop.
Save Goldenflamer/d903bc015c0f81bddfb4ac8089ab4884 to your computer and use it in GitHub Desktop.
Set a cookie via a php script by using input fields
<form action="<?php print($_SERVER['PHP_SELF']);?>" method="post">
<p>Cookie-Name<input type="text" name="name" /></p>
<p>Cookie-Value<input type="text" name="value" /></p>
<p><input type="submit" /></p>
</form>
<?php
if(isset($_POST['name']) && isset($_POST['value']))
{
//keep in mind that $_SERVER['HTTP_HOST'] is insecure!
setcookie($_POST['name'], $_POST['value'], 2147483647, "/",$_SERVER['HTTP_HOST'], true, true);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment