userloginmanager.cs

来自「酒店管理 主要实现了基础设施管理(客房管理、客房类型管理)、业务管理(入住、退」· CS 代码 · 共 33 行

CS
33
字号
using System;
using System.Collections.Generic;
using System.Text;

using System.Web.Security;
using System.Web;

namespace BLL
{
    /// <summary>
    /// 用户登陆管理类(身份验证)
    /// </summary>
    public class UserLoginManager
    {
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="username"></param>
        public void AuthenticationUsers(string username)
        {
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddHours(24), true, "");
            //身份验证票证
            string hashTicket = FormsAuthentication.Encrypt(ticket);
            HttpCookie userCookie = new HttpCookie(FormsAuthentication.FormsCookieName);
            userCookie.Value = hashTicket;
            userCookie.Expires = ticket.Expiration;
            userCookie.Domain = FormsAuthentication.CookieDomain;
            //将新建的Cookie添加到当前的响应Cookies集合中
            HttpContext.Current.Response.Cookies.Add(userCookie);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?