下载后可任意编辑C#实现访客浏览历史记录(足迹)的方法:cookiestringcookie 记录用户浏览的 ID,格式为-1-2-3-4-5-。#region 存储 cookie set(key,value,days)public static bool set( string strName, string strValue, int strDay ){try{HttpCookie Cookie = new HttpCookie( strName );Cookie.Domain = GetHost(); /* 当 要 跨 域 名 访 问 的 时 候 , 给cookie指定域名即可,xxxx */Cookie.Expires = DateTime.Now.AddDays( strDay );Cookie.Value = strValue;HttpContext.Current.Response.Cookies.Add( Cookie );return(true);}catch{return(false);}}#endregion#region 读取cookie值 get(key)public static string get( string strName ){HttpCookie Cookie = HttpContext.Current.Request.Cookies[strName];if ( Cookie != null ){return(Cookie.Value.ToString() );}else {return(null);}}#endregion#region 用 户 历 史 记 录 public static void history( string id ){varisHit= false;varhistory = Cookie.get( “history” );if ( string.IsNullOrEmpty( history ) ){CookieHelper.Cookie.set( “history”, “-” + id + “-”, 1 );isHit = true;}else {/* -1-2-3-4-5-6-7- */if ( history.Contains( “-” + id + “-” ) ){history = history.Replace( “-” + id, ““ );history = “-” + id + history;}else {history = “-” + id + history;isHit= true;}Cookie.set( “history”, history );}if ( isHit ){/* 用户浏览写入数据库 */}}#endregion1