asp.net - 关闭应用程序后延长 Cookie 的生命周期
问题描述
我在 asp.net 中有一个应用程序,我在其中创建了一个具有定义时间的 cookie,这个时间是在我实时执行应用程序时完成的
我想看看我应该如何定义 cookie,以便即使应用程序没有运行,它也能持续实现的时间
我需要帮助来实现当应用程序稍后运行并且浏览器中存在该 cookie 时,根据 cookie 的值加载默认数据
我已经从页面加载方法 pointB.aspx.cs 中定义了 cookie
应用程序关闭并再次运行后,使用 pointB.aspx.cs 的 page_load 中的 cookie
点A.aspx.cs
namespace Test
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie apple = new HttpCookie("apple", "0");
apple.Expires = DateTime.Now.AddMinutes(30);
Response.Cookies.Add(apple);
Response.Write("<script>alert('Apple cookie has been Created');</script>");
}
}
}
pointB.aspx.cs
namespace Test
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["apple"]flagUserType != null)
{
Response.Write("<script>alert('Apple can be eaten');</script>");
Response.Write("<script>alert('"+ Request.Cookies["apple"].Value.ToString() +"');</script>");
}
}
}
}
请帮忙 :)
解决方案
推荐阅读
- javascript - 如何解析定义函数的 JSON 字符串
- flutter - 以自定义时间间隔显示重复的本地推送通知
- mysql - 如何限制多个JOIN中的行内容
- dockerfile - docker image websphere9问题,暴露其他端口时控制台不起作用
- python-3.x - Youtube Data API:获取总评论、喜欢、不喜欢
- android - Android 9 上的生物识别管理器
- autodesk-forge - Autodesk.Forge:未加载设计自动化 App Bundle
- symfony - Shopware 6 计划任务未运行
- python-3.x - 如何在使用 django-import-export 的 excel 导入期间避免类似的行?
- python - 如何在侧面构建这个缩放屏幕?