Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpCookie Expires and IIS setting
    primarykey
    data
    text
    <p>I am getting crazy with Cookie Expire date, conceptually it is pretty simple but it is not working on my server... I guess that's an IIS setting that's making me crazy, what do you think????</p> <p>I started with an MVC 3 sample project and I am adding the following code in the Home Controller</p> <pre><code> public ActionResult Index() { var PersistentLogonCookieName = "test"; var persistentLogon = DateTime.Now.ToLongTimeString(); var persistentLogonCookie = new HttpCookie(PersistentLogonCookieName, persistentLogon); persistentLogonCookie.Expires = DateTime.UtcNow.AddDays(2); if (Request.Cookies[PersistentLogonCookieName] == null) { ViewBag.Message = "Cookie NOT Found!"; persistentLogonCookie.Value = "added" + DateTime.Now.ToLongTimeString(); Response.Cookies.Add(persistentLogonCookie); } else { ViewBag.Message = "Cookie Found!"; Response.SetCookie(persistentLogonCookie); } return View(); } </code></pre> <p>if I run it locally, it works fine after the second request I got Cookie Found.... if I run on the server I got always Cookie Not Found.... If I comment <code>persistentLogonCookie.Expires = DateTime.UtcNow.AddDays(2);</code> it works fine also on the server. I don't know what to think about if not that's a different IIS settings between my local machine and the server.... In the response header I have: </p> <pre><code>Set-Cookie test=added4:23:39 PM; expires=Wed, 14-Aug-2013 15:23:39 GMT; path=/ </code></pre> <p>but the cookie is not added to the cookie collection of following requests when I test it on the server and it goes in the cookie collection when I test with my local IIS.... Any suggestion would be highly appreciated....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload