JavaScript reads and writes the delete cookie operation.
function Getcookieval (offset)
Get the value of the cookie after decoding
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr = = 1)
Endstr = Document.cookie.length;
Return unescape (document.cookie.substring (offset, endstr));
}
---------------------------
function Setcookie (name, value)
Set cookie Value
{
var expdate = new Date ();
var argv = setcookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2)? ARGV[2]: null;
var path = (argc > 3)? ARGV[3]: null;
var domain = (argc > 4)? ARGV[4]: null;
var secure = (argc > 5)? ARGV[5]: false;
if (expires!=null) Expdate.settime (Expdate.gettime () + (expires * 1000));
Document.cookie = name + "=" + Escape (value) + ((expires = null)? "" : ("; Expires= "+ expdate.togmtstring ()))
+ ((path = null)? "" : ("; Path= "+ path") + ((domain = null)? "" : ("; domain= "+ domain)"
+ (Secure = = True)? "; Secure ":" ");
}
---------------------------------
function Delcookie (name)
Delete Cookies
{
var exp = new Date ();
Exp.settime (Exp.gettime ()-1);
var cval = GetCookie (name);
Document.cookie = name + "=" + Cval + "; Expires= "+ exp.togmtstring ();
}
------------------------------------
function GetCookie (name)
Get the original value of the cookie
{
var arg = name + "=";
var alen = Arg.length;
var clen = document.cookie.length;
var i = 0;
while (I < Clen)
{
var j = i + Alen;
if (Document.cookie.substring (i, j) = arg)
Return Getcookieval (j);
i = Document.cookie.indexOf ("", I) + 1;
if (i = = 0) break;
}
return null;
}