gpt4 book ai didi

c# - Cookie 在 MAC -Safari 和 IOS Mobile- Safari 中不起作用

转载 作者:行者123 更新时间:2023-11-30 12:56:08 25 4
gpt4 key购买 nike

我正在创建一个模型,序列化并分配到 cookie 中并将其传递给下一页。我能够在所有浏览器的下一页中获取 cookie 值,除了

  • MAC -Yoshemite - Safari
  • IOS - IPHONE 6 移动版 - Safari

    我需要更新以下代码才能在 Safari 中工作吗?

    string CookieName= "dsResponse";
    string json = new JavaScriptSerializer().Serialize(model);

    if (HttpContext.Current.Request.Cookies[CookieName] != null)
    {
    HttpContext.Current.Response.Cookies[CookieName].Expires = DateTime.Now.AddDays(-1);
    }
    HttpContext.Current.Response.SetCookie(new HttpCookie(CookieName)
    {
    Value = json,
    HttpOnly = false,
    Expires = DateTime.Now.AddSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["cookiesecond"]))
    });

最佳答案

第一:您正在覆盖 cookie - 而不是使用此代码使其过期。响应对象发送一次 - 与您的"new"cookie。如果 cookie 存在 - 只需更改其值和/或内容。我会检查你对 AppSettings["cookiesecond"]

的假设

也试试这个:

If Request.ServerVariables("http_user_agent").IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) <> -1 Then
Me.Page.ClientTarget = "uplevel"

可能是浏览器大小写不匹配...

关于c# - Cookie 在 MAC -Safari 和 IOS Mobile- Safari 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43282615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com