Could you tell me what I am doing wrong here. Why cookies are not saved when the page reloads:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // it is always null !!!! if (Response.Cookies["user_id"].Value != null) { //code never gets here } } }
and this is the code for storing the cookie (after clicking on the check box):
protected void CheckBoxRememberMe_Click(object sender, EventArgs e) { Response.Cookies["user_id"].Value = tbUserID.Text; Response.Cookies["user_id"].Expires = DateTime.Now.AddDays(15); }
So: I click on the checkbox, the value of the tbUserID text field is stored in the HttpCookie, then I reload the page (update), and the value is null.
Any idea?
Ranch source share