<html>
<head>

<title>Cookies Set/Get</title>
</head>

<body bgcolor=lightyellow>
<h1>Create and Read Cookies</h1>

<form method=post name=frm action=/~sultans/php/demo/5session/cookie.php?option=set > 
<fieldset style='width:340px'>
<table>
<tr><td>Enter cookie name<td> <input type=text name=cookie>
<tr><td>Enter cookie value<td><input type=text name=value>
<tr><td valign=top>Number of days to expire<td><input type=text name=expire value=1> 
                                <br>(negative num to delete)  </td>
</table>
</fieldset>
<br>
<input type=submit value="Create Cookie" onClick="return validate_create()">
<input type=submit value="View Cookies"  onClick="return validate_view()">
</form>

<script>
function validate_create() 
{
	if (document.frm.cookie.value == '')
	{
		alert("Please enter cookie name")
		return false
	}
	if (isNaN(document.frm.expire.value) )
	{
		alert("Please enter valid expiration days")
		return false
	}
}
function validate_view() 
{
	document.frm.cookie.value = '';		//erase the cookie name
	document.frm.value.value  = '';		//erase the cookie value
}
</script>
</body>
</html>