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:
- this in development , localhost , port not changed during several running.
- i've checked browser settings , doesn't deletes cookies upon close.
Comments
Post a Comment