/// <summary>
/// 插入cookie 代码添加过期时间为一分钟
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
private string GetScript(string code)
{
StringBuilder cookieInfo = new StringBuilder();
cookieInfo.Append("var exDate = new Date();");
cookieInfo.Append("exDate.setTime(exDate.getTime() + 60 * 1000);");
cookieInfo.Append("document.cookie="");
cookieInfo.Append("ValidateCode=");
cookieInfo.Append(des.MD5Encrypt(code.ToLower()));
cookieInfo.Append(";path=/");
cookieInfo.Append(";domain=baidu.com");
cookieInfo.Append(";Expires=" + ");
cookieInfo.Append("exDate.toGMTString();");
return cookieInfo.ToString();
}
//生成效果 var exDate = new Date();exDate.setTime(exDate.getTime() + 60 * 1000);document.cookie="ValidateCode=99fd2fecf15f4136f09bf0007a25c10e;path=/;domain=baidu.com;Expires=" + exDate.toGMTString();
//前台使用eval即可生成对应cookie