- Codes below is to update value into existing cookie.
- These codes working fine but now the I have no idea why it breaks and unable to update the latest value into cookie. (Cookie keep showing first assigned value).
- Example flows: a) The first assigned value in cookie is "abc". b) Update "123" as latest value into cookie. c) Read cookie but value remains "abc".
I have tried in Microsoft Edge where the cookie updates worked as expected but no idea why google chrome is failed to update cookie.
string m_cookie = FormsAuthentication.FormsCookieName; string m_Json = string.Empty; HttpCookie m_httpCookie; FormsAuthenticationTicket m_ticket; m_httpCookie = System.Web.HttpContext.Current.Request.Cookies[m_cookie]; m_ticket = FormsAuthentication.Decrypt(m_httpCookie.Value); m_Json = (JsonConvert.SerializeObject(new UserCredential1 { UserName = "123", ExpiredAt = "123", AccessToken = "123", TokenType = "123", })).ToString(); var newticket = new FormsAuthenticationTicket(m_ticket.Version, m_ticket.Name, m_ticket.IssueDate, dtNowAdd1min, false, m_Json, m_ticket.CookiePath); m_httpCookie.Value = FormsAuthentication.Encrypt(newticket); if (newticket.IsPersistent) m_httpCookie.Expires = newticket.Expiration; System.Web.HttpContext.Current.Response.Cookies.Set(m_httpCookie); m_httpCookie = System.Web.HttpContext.Current.Request.Cookies[m_cookie]; m_ticket = FormsAuthentication.Decrypt(m_httpCookie.Value); UserCredential result = JsonConvert.DeserializeObject<UserCredential>(m_ticket.UserData);I'm suspecting this happens due to Google Chrome Samesite settings?
- Anyone have idea about this? Thanks in advance.