First, after the user submits the comment, lets the client cookies record the correlation value, for example: The ASP under the cookie assignment method uses the following statement:
Copy Code code as follows:
Response.Cookies ("username") = "Name"
Response.Cookies ("username"). expires=date+30
Assign value to cookies through the above ASP program. How do I read this cookie in the static page HTML and display it in the user? Because it is generated HTML, we can no longer use the ASP program to read this cookie, need to read this cookie through JS, and given to the corresponding input value.
Use JS to read cookies and assign values to the following code:
Copy Code code as follows:
<script type= "Text/javascript" >
JS Get Cookie
var acookie=document.cookie.split (";");
function Getck (sname)
{//Get a single cookie
for (Var i=0;i<acookie.length;i++) {
var arr=acookie[i].split ("=");
if (Sname==arr[0]) {
if (arr.length>1)
Return unescape (arr[1]);
Else
Return "";
}}
Return "";
}
Assign values to the input in the corresponding form
DOCUMENT.FORM_NAME.INPUT_NAME.VALUE=GETCK ("username");
</script>
In this way, the static page can be successfully read from the client cookies information, and display.