Tip: you can modify some code before running
Js sets cookie and obtains cookie value instance code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Js sets cookie and obtains cookie value instance code</title></head><body><form id="f" name="f" method="post" action=""> <input name="" type="button" value="设置cookie" onclick="setcookie('cn','aa',10);"/> <input name="" type="button" value="读取cookie" onclick="getcookie('cn');" /></form><script language="javascript">Function setcookie (name, value, days) {var exp = new Date (); exp. setTime (exp. getTime () + days * 24x60*60*1000); document. cookie = name + "=" + escape (value) + "; expires =" + exp. toGMTString (); alert ('success');} function getcookie (name) {var arr = document. cookie. match (new RegExp ("[sS] *" + name + "= ([^;] *) (; | $)"); alert (arr ); if (arr! = Null) return unescape (arr [1]); return null ;}</script></body></html>
Tip: you can modify some code before running