c# - Cookie getting unset when a read attempt is made? -


There is a strange problem for you.

I have created a control that puts a record in a database and writes a cookie to the user's machine here's the cookie writing code snippet:

  protected void CreateCookie (Guid id, DateTime expires) {var oCookie = new HttpCookie ("gsow"); OCookie.Value = id.ToString (); OCookie.Expires = ends; HttpContext.Current.Response.Cookies.Add (oCookie); }  

Very simple, nothing fancy. The id is passed through the function which writes the entry in the database and this id is generated on the fly. Now the code for my cookie readings is:

  Protected Zero Page_load (object sender, eventArgues E) {var oCookie = HttpContext.Current.Response.Cookies ["gsow"]; Output.Text = "I'm here" 
"; If (ocu! = Null) output. Text + oaku.value; Else output2.Text = "no cookie."; }

Once again, it is very easy. Here are the steps I have taken and repeated many times:

  1. Make a cookie / db entry by launching the first page.
  2. Confirm cookie / db entry (the steps they perform on this, checked by Chrome's cookie manager)
  3. Launch the second page

Once I load the second page, I should stop the ID that I set earlier, the cookie still exists but it is unset.

Here I have a screenshot of the cookie after loading the first page:

alt text

And once I load another page:

So what I'm seeing, when I load the second page, the value of the cookie ends / expires.

To get the best of my knowledge, you retrieve cookies using the request object Should not, Response object is not


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -