<html>
<head>

<title>Web Session Set/Get</title>
</head>

<body bgcolor=lightyellow>
<h2>Create and View Session Variables</h2>

<form method=post name=frm > 
<fieldset style='width:340px'>
<table>
<tr><td>Enter variable name<td> <input type=text name=varName>
<tr><td>Enter variable value<td><input type=text name=varValue>
</table>
</fieldset>
<br>
<input type=submit value="Start Web Session" onClick="start_session()" style="width:338px">   
<div  style="margin-top:5px">
<input type=submit value=" Set Variable "  onClick="create_var()" style="width:110px; color:white; background-color:2C2C2C">
<input type=submit value="Delete Variable" onClick="delete_var()" style="width:110px; color:white; background-color:2C2C2C">    
<input type=submit value="View Variables"  onClick="view_vars()"  style="width:110px; color:white; background-color:2C2C2C">
<div style="margin-top:5px">
<input type=submit value="End Session" onClick="end_session()" style="width:338px">   
</form>

<script>
action = "/~sultans/python/demo/5cookie/session.py"

function start_session() 
{
    alert('Starting a New Session or Accessing Existing Session')
    document.frm.action = action + "?option=start"
    document.frm.submit()
}
function create_var() 
{
    if (document.frm.varName.value == '' || document.frm.varValue.value == '')
        alert("Please enter variable name and value")
    else
    {
        document.frm.action = action + "?option=set"
        document.frm.submit();
    }
}
function delete_var() 
{
    if (document.frm.varName.value == '' )
        alert("Please enter variable name to delete")
    else
    {
        document.frm.action = action + "?option=del"
        document.frm.submit()
    }
}
function view_vars() 
{
    document.frm.action = action + "?option=view"
    document.frm.submit()
}
function end_session() 
{
    alert('Ending the Session')
    document.frm.action = action + "?option=end"
    document.frm.submit()
}
</script>
</body>
</html>