我如何在页面中保存Cookie

我如何在页面中保存Cookie

本文介绍了我如何在页面中保存Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我想从当前页面移至另一页面,所以我使用了以下代码:

Hi.

i want to move from current page to another page so i used this code:

Response.Redirect("~/Education.aspx");



但是我的问题是,当用户在浏览器中按Back时,上一页会释放他的cookie,并且该页的文本框中不会有任何数据.



but my problem is when user press Back in Browser , the previous page looses his cookies and there won''t be any data inside textbox in page.

推荐答案

protected void Page_Load(object sender, EventArgs e)
{
  if (Request.Cookies["Email"] != null)
  {
     txtEmail.Text = Request.Cookies["Email"].Value;
  }
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
  Response.Cookies["Email"].Value = txtEmail.Text;
  Response.Cookies["Email"].Expires = DateTime.Now.AddDays(30);
}



或浏览给定的页面链接:
使用RememberMe CheckBox和ASP.Net中的Cookie [ ^ ]

一切顺利.



Or Go through given page link:
Remember UserName and Password using RememberMe CheckBox and Cookies in ASP.Net[^]

All the best.



Response.Cookies["test"].Expires = DateTime.Now.AddYears(1);


检查此
http://www.aspnettutorials.com/tutorials/network/cookies-csharp.aspx [ ^ ]
http://www.dotnetfunda.com/articles/article1404-how- to-read-cookies-in-aspnet.aspx [ ^ ]
ASP.NET中的Cookie [ ^ ]
有关ASP.NET C#中Cookie的所有信息 [ ^ ]
http://msdn.microsoft.com/en-us/library/ms178194.aspx [ ^ ]
最好的问候
米特瓦里(M.Mitwalli)


Check this
http://www.aspnettutorials.com/tutorials/network/cookies-csharp.aspx[^]
http://www.dotnetfunda.com/articles/article1404-how-to-read-cookies-in-aspnet.aspx[^]
Cookies in ASP.NET[^]
all thing about cookies in asp.net c#[^]
http://msdn.microsoft.com/en-us/library/ms178194.aspx[^]
Best Regards
M.Mitwalli


这篇关于我如何在页面中保存Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:27