ExploitationCookie: Cookie is used by a browser to store a small amount of named data. It is associated with a specific webpage or website.
Cookies are used to provide the browser with memory so that scripts and server programs can use the input data of another page on one page.
Post.htm
The following is a reference clip:
<Input type = "text" name = "txt1">
<Input type = "button" value = "Post">
<Script language = "javascript">
Function setCookie (name, value)
{
/*
* --------------- SetCookie (name, value )-----------------
* SetCookie (name, value)
* Function: set the value of the variable name.
* Parameter: name, string; value, String.
* Instance: setCookie ('username', 'baobao ')
* --------------- SetCookie (name, value )-----------------
*/
Var Days = 30; // This cookie will be saved for 30 Days
Var exp = new Date ();
Exp. setTime (exp. getTime () + Days x 24x60*60*1000 );
Document. cookie = name + "=" + escape (value) + "; expires =" + exp. toGMTString ();
Location. href = "Read.htm"; // receiving page.
}
</Script>
Read.htm
The following is a reference clip:
<Script language = "javascript">
Function getCookie (name)
{
/*
* --------------- GetCookie (name )-----------------
* GetCookie (name)
* Function: Get the variable name value.
* Parameter: name, String.
* Instance: alert (getCookie ("baobao "));
* --------------- GetCookie (name )-----------------
*/
Var arr = document. cookie. match (new RegExp ("(^ |)" + name + "= ([^;] *) (; | $ )"));
If (arr! = Null) return unescape (arr [2]); return null;
}
Alert (getCookie ("baobao "));
</Script>
Advantage: it can be accessed from any webpage in the same source. The lifecycle can be set.
Disadvantage: The value length is limited.