<script type="text/javascript">

function setCookie (sName, sValue, oExpires, sPath, sDomain, bSecure) (
var sCookie = sName + "=" + encodeURIComponent (sValue);
/ / Failure time
if (oExpires) (
sCookie + = "; expires =" + oExpires.toGMTString ();
)
/ / Path
if (sPath) (
sCookie + = "; path =" + sPath;
)
/ / Domain
if (sDomain) (
sCookie + = "; domain =" + sDomain;
)
/ / Safety signs
if (bSecure) (
sCookie + = "; secure =" + bSecure;
)
/ / Return the complete Cookies
document.cookie = sCookie;
)

function getCookie (sName) (
/ / Is that the pattern
var sRE = "(?:;)? "+ sName + "=([^;]*);?";
/ / Create regular expression object
var oRE = new RegExp (sRE);
/ / Use the test to test whether or not to meet the definition of the format
if (oRE.test (document.cookie)) (
return decodeURIComponent (RegExp [ "$ 1"]);
) else (
return null;
)
)
function deleteCookie (sName, sPath, sDomain) (
var sCookie = sName + "=; expires =" + (new Date (0)). toGMTString ();
if (sPath) (
sCookie + = "; path =" + sPath;
)
if (sDomain) (
sCookie + = "; path =" + sDomain;
)
document.cookie = sCookie;
)
</ script>
<body>
This is my JSP cookie page. <br>
<hr>
<script type="text/javascript">
alert ( "Setting cookies");
setCookie ( "name", "aa");
setCookie ( "info", "bb");
/ / get value of cookie
alert ( "The value of cookie 'name' is:" + getCookie ( "name"));
alert ( "The value of cookie 'info' is:" + getCookie ( "info"));

alert ( "delete info");
deleteCookie ( "info");
alert ( "The value of cookie 'name2' is:" + getCookie ( "name"));
alert ( "The value of cookie 'info2' is:" + getCookie ( "info"));

</ script>
</ body>
</ html>