This article provides operations on cookies. Let's take a look at how to set and delete cookie instances in js. Cookie is a txt file used by the client to save information.
This article provides operations on cookies. Let's take a look at how to set and delete cookie instances in js. Cookie is a txt file used by the client to save information.
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<Html xmlns = "http://www.aimeige.com.cn/1999/xhtml">
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = gb2312"/>
<Title> setting and deleting cookies in js </title>
<Script>
Function setcookie (sname, svalue, sexpires)
{
Var scookie = sname + "=" + encodeuricomponent (svalue );
If (sexpires! = Null)
{
Scookie + = "; expires =" + sexpires;
}
Document. cookie = scookie;
}
Function removecookie (sname, svalue)
{
Document. cookie = sname + "=; expires = fri, 31 dec 1999 23:59:59 gmt ;";
}
// Set cookie
Setcookie ('bkjia. c0m', 'www. bKjia. c0m', 'fri, 31 dec 2030 23:59:59 gmt ;')
// Delete the cookie
Removecookie ('bkjia. c0m', 'www. bKjia. c0m ')
</Script>
</Head>
<Body>
</Body>
</Html>