Chrome SameSite验证阻止cookie更新

问题描述

我有一个旧的.net站点(使用.net 4.6),当用户从一页转到另一页时,该站点在cookie中存储了一些临时值。该站点只能在我们公司的内部网络上访问,并且仅使用HTTP。当前是流程:

Page 1 -> Creates the cookie. Stores session token.
Page 2 -> Adds receipt id to cookie (happens in .net code - see below)
Page 3 -> Reads receipt id from cookie and does something with it. 

这一切在Chrome将SameSite=Lax设置为认值之前就可以使用。我进行了测试,并且如果我禁用了chrome://flags/#same-site-by-default-cookies(本质上设置了SameSite=None),则第2页可以成功更新cookie,一切正常。没有SameSite=None,Page2无法更新cookie,因此Page 3无法使用它(cookie实际上不会更新)。

设置Cookie的代码

/// <summary>
/// This function is used to update UserCookieWrapper values
/// </summary>
/// <param name="item">Can be a stirng</param>
/// <param name="val">Can be a string</param>
/// <param name="expireHours">Must be a double</param>
private static void UpdateCookieVal(COOKIE_ITEM item,string val,double expireHours){
     //get the existing cookie (or new if not exists)
     HttpCookie cookie = GetAppCookie(true);
     
     //modify its contents & Meta.
     if(RememberMe)
         cookie.Expires = DateTime.Now.AddHours(clsBLLConstants.APP_COOKIE_EXIPRYHOURS);

     cookie.Values[item.ToString()] = clsEncryption.EncryptPassword(val,clsBLLConstants.initVector,clsBLLConstants.saltValue,clsBLLConstants.passphrase,clsBLLConstants.hashAlgorithm,clsBLLConstants.passwordIterations,clsBLLConstants.keySize);
     //add back to the http response to send back to the browser
     HttpContext.Current.Response.Cookies.Add(cookie);
     try
        {
           HttpContext.Current.Response.Cookies.Add(cookie);
     } catch (Exception exception) {
           clsBLLErrorHandler.WriteError(exception);
     }

}

这是cookie的样子:

enter image description here

问题:

  1. 我的所有页面都在同一站点上。为什么SameSite在这里有意义?
  2. 该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...