c# - Why my cookies expiration is not working -


i have following code:

protected void page_load(object sender, eventargs e) {         if (request.cookies["mytestcookie"] == null)         {             string str = "some string";             httpcookie mycookie = new httpcookie("mytestcookie")             {                 value = str,                 expires = datetime.now.addyears(50)             };             httpcontext.current.response.setcookie(mycookie);         }  } 

but works until close browser. if close browser , compile , run project again code inside if block executes again. question why cookies expiration doesn't work , cookie expiring after close browser?

some notes:

  1. this in development , localhost , port not changed during several running.
  2. i've checked browser settings , doesn't deletes cookies upon close.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -