Share it online.
Function K_getcookieval (offset)
{
VaR Endstr = Document. Cookie. indexof ( " ; " , Offset );
If (Endstr = - 1 )
Endstr = Document. Cookie. length;
Return Unescape (document. Cookie. substring (offset, endstr ));
}
Function K_setcookie (name, value)
{
VaR Expdate = New Date ();
VaR Argv = K_setcookie.arguments;
VaR Argc = K_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 K_delcookie (name)
{
VaR Exp = New Date ();
Exp. settime (exp. gettime () - 1 );
VaR Cval = Getcookie (name );
Document. Cookie = Name + " = " + Cval + " ; Expires = " + Exp. togmtstring ();
}
Function K_getcookie (name)
{
VaR ARG = Name + " = " ;
VaR Alen = Arg. length;
VaR Clen = Document. Cookie. length;
VaR I = 0 ;
While (Clen > I)
{
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 ;
}