Created
May 25, 2010 05:31
-
-
Save jarsen/412805 to your computer and use it in GitHub Desktop.
This file contains hidden or 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($_REQUEST['name'])) { | |
// echo "Setting cookie..."; | |
if(!setcookie($_REQUEST['name'],$_REQUEST['value'],time() + $_REQUEST['exp'])) { | |
echo "ERROR: cookie not set!"; | |
} | |
} | |
?> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Homework 3 | Problem 2</title> | |
</head> | |
<body> | |
<h1>Cookie Factory</h1> | |
<form action="hw3.php" method="post"> | |
<table> | |
<tr><td>Cookie Name: </td><td><input type="text" name="name" /></td></tr> | |
<tr><td>Cookie Value: </td><td><input type="text" name="value"/></td></tr> | |
<tr><td>Cookie Expiration: </td><td><input type="text" name = "exp"/></td></tr> | |
</table> | |
<p><input type="submit"/> </p> | |
</form> | |
<?php if(!empty($_COOKIE)) { | |
print_r($_COOKIE);?> | |
<h2>Cookies on your machine:</h2> | |
<table> | |
<tr> | |
<th>Name</th> | |
<th>Value</th> | |
</tr> | |
<?php foreach(array_keys($_COOKIE) as $key) {?> | |
<tr> | |
<td><?php echo $key?></td> | |
<td><?php echo $_COOKIE[$key]?></td> | |
</tr> | |
<?php } // end foreach ?> | |
</table> | |
<?php } // end if?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment