YongHu_UI/Model/IdentityManager.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Clothes.BLL;
using Clothes.Comment;
using Clothes.IBLL;
using Clothes.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
namespace YongHu_UI.Model
{
public class IdentityManager
{
/// <summary>
/// 保存用户信息
/// </summary>
/// <param name="user"></param>
public static void SaveUser(CLLogin user)
{
if (user == null)
{
return;
}
// 序列化用户资料
string profileString = user.Id.ToString();
// 生成身份票据
DateTime timeNow = DateTime.Now;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
user.Id.ToString(),
timeNow,
timeNow.AddMonths(1),
false,
profileString,
FormsAuthentication.FormsCookiePath);
string ticketString = FormsAuthentication.Encrypt(ticket);
// 保存身份票据到Cookie
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, ticketString);
cookie.Expires = timeNow.AddMonths(1);
HttpContext.Current.Response.Cookies.Set(cookie);
}
/// <summary>
/// 读取用户信息
/// </summary>
/// <returns></returns>
public static CLLogin ReadUser()
{
// 读取身份
string ticketString = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]?.Value;
if (string.IsNullOrWhiteSpace(ticketString))
{
return default;
}
后面还有 19 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。