What you see in a book is that users writeArticleEvery certain time, the user's articles are automatically saved with cookies. For more information, see.
Update.html
<! 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 = UTF-8"/>
<Title> untitled document </title>
<SCRIPT type = "text/JavaScript" src = "JS/ajax. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
VaR Ajax = new ajaxrequest ();
Function temp (){
VaR OBJ = Document. getelementbyid ("AJ"). value;
If (OBJ ){
Ajax. postf (
"P ",
Function (OBJ ){},
"Update. php ",
"Post ");
} Else {
VaR obj2 = getcookie ("content ");
Alert (obj2 );
Document. getelementbyid ("AJ"). value = obj2;
}
}
Setinterval ("Temp ();", 3000 );
Function setcookie (name, value)
{
VaR days = 3;
VaR exp = new date ();
Exp. settime (exp. gettime () + days * 60x60*1000 );
Document. Cookie = Name + "=" + encodeuricomponent (value) + "; expires =" + exp. togmtstring ();
}
Function getcookie (name)
{
VaR arr = Document. Cookie. Match (New Regexp ("(^ |)" + name + "= ([^;] *) (; | $ )"));
If (Arr! = NULL) return decodeuricomponent (ARR [2]);
Return
NULL;
}
Function delcookie (name)
{
VaR exp = new date ();
Exp. settime (exp. gettime ()-1 );
VaR cval = getcookie (name );
If (cval! = NULL) document. Cookie = Name + "=" + cval + "; expires =" + exp. togmtstring ();
}
</SCRIPT>
</Head>
<Body>
<Form action = "Update. php" method = "Post" id = "p">
<P>
<Textarea name = "content" Cols = "50" rows = "10" id = "AJ"> </textarea>
</P>
<P>
<Input type = "hidden" name = "action" value = "save"/>
<Input name = "" type = "Submit" value = "style" style = "margin-top: 20px; width: 250px; Height: 40px;"/>
</P>
</Form>
</Body>
</Html>
Update. php
<? PHP
Header ("Content-Type: text/html; charset = UTF-8 ");
If ($ _ post ['action'] = 'save '){
$ Content = $ _ post ['content'];
// Temporarily Save the submitted data to the cookie
$ Cookietime = Time () + 7200;
Setcookie ('content', $ content, $ cookietime );
Echo $ content;
}?>