<html>
<head>
<title>Cookies Set/Get</title>
</head>
<body bgcolor=lightyellow>
<h2>Create and View Cookies</h2>
<form method=post name=frm action=/~sultans/python/demo/5cookie/cookie.py?option=set >
<fieldset style='width:355px'>
<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=button value="Create Cookie" onClick='validate_create()'>
<img src=cookie.jpg height=15px width=15px onClick='validate_create()'>
<input type=button value="View Cookies" onClick='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
}
if (document.frm.expire.value >= 0 && ! document.frm.value.value)
{
alert("Please enter cookie value")
return false
}
document.frm.submit();
}
function validate_view()
{
document.frm.cookie.value = ''; //erase the cookie name
document.frm.value.value = ''; //erase the cookie value
document.frm.submit();
}
</script>
</body>
</html>