日期:2014-05-17 浏览次数:20398 次
using System;
using System.Web;
using Model;
/// <summary>
///LoginUser 的摘要说明
/// </summary>
public class LoginUser
{
private HttpCookie Cookie;
// 登录
public static void Login(LoginInfo user)
{
LoginUser login = new LoginUser();
login.WriteCookie("Ihdy", user.UserId);
login.WriteCookie("Ymxe", user.UserName);
login.WriteCookie("Dmdy", user.Passd);
login.WriteCookie("Xgng", user.Name);
}
// 退出
public static void Logout()
{
LoginUser login = new LoginUser();
login.CookieRemoves("Ihdy");
login.CookieRemoves("Ymxe");
login.CookieRemoves("Dmdy");
login.CookieRemoves("Xgng");
}
/// <summary>
/// 添加Cookie
/// </summary>
/// <param name="cookieName"></param>
/// <param name="obj"></param>
private void WriteCookie(string cookieName, object obj, bool Ext = true)
{
if (obj != null)
{
Cookie = new HttpCookie(cookieName);
Cookie.Value = Ext ? HttpUtility.UrlEncode(obj.ToString().Ext_GetEncrypt()) : obj.ToString();
HttpContext.Current.Response.Cookies.Add(Cookie);
}
}
/// <summary>
/// 清除cookie
/// </summary>
/// <param name="cookeName">&