What are Cookies?
Web Browser and Server use HTTP protocol to communicate and HTTP is a
stateless protocol. But for a commercial website, it is required to
maintain session information among different pages. For example, one
user registration ends after completing many pages. But how to maintain
user's session information across all the web pages.
Example:
Following is the example to set a customer name in
input cookie.
<html>
<head>
<script type="text/vbscript">
Function WriteCookie
If document.myform.customer.value="" Then
msgbox "Enter some value!"
Else
cookievalue=(document.myform.customer.value)
document.cookie="name=" + cookievalue
msgbox "Setting Cookies : " & "name=" & cookievalue
End If
End Function
</script>
</head>
<body>
<form name="myform" action="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" onclick="WriteCookie()"/>
</form>
</body>
</html>
This will produce the following result. Now enter something in the text
box and press the button "Set Cookie" to set the cookies.
Comments