简体   繁体   English

IFrame 和 safari 不再支持第 3 方 cookies

[英]IFrame with safari no longer support 3rd party cookies

I'm trying to access cross site url though IFrame and xyz.com is loading inside IFrame.我正在尝试访问跨站点 url 虽然 IFrame 和 xyz.com 正在加载 ZD7487406B56237. 在此处输入图像描述

in xyz.com we have used asp.net membership module and we are using SetAuthCookie.在 xyz.com 中,我们使用了 asp.net 会员模块,我们正在使用 SetAuthCookie。

FormsAuthentication.SetAuthCookie(userName, false); FormsAuthentication.SetAuthCookie(userName, false);

previously we were able to access these auth cookies in safari by using following logic by accessing top frame href by referrer.以前,我们可以通过使用以下逻辑通过引用者访问顶部帧 href 来访问 safari 中的这些 auth cookies。

  <script>
    window.onload = function () {        
        if (navigator.userAgent.indexOf('Safari') != -1 && (navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPad') != -1)) {              
            var cookies = document.cookie;
            if (top.location != document.location) {
               
                if (!cookies) {
                    href = document.location.href;
                    href = (href.indexOf('?') == -1) ? href + '?' : href + '&';
                    top.location.href = href + 'reref=' + encodeURIComponent(document.referrer);                      
                }
            } else {
                
                ts = new Date().getTime(); document.cookie = 'ts=' + ts;
                rerefidx = document.location.href.indexOf('reref=');
                if (rerefidx != -1) {
                    href = decodeURIComponent(document.location.href.substr(rerefidx + 6));
                    window.location.replace(href);                    
                }
            }
          
            var redirectValue = document.getElementById('hgvRedirectValueHiddenField').value;
            if (redirectValue != "") {
                window.open(redirectValue, '_self');
            }
        }

    }

</script>

But with the latest updates safary not allows to set但是随着最新的更新 safary 不允许设置

 top.location.href = href + 'reref=' + encodeURIComponent(document.referrer);

and auth cookie seems no longer allows and getting following error并且 auth cookie 似乎不再允许并出现以下错误

The frame attempting navigation of the top-level window is cross-origin or untrusted and the user has never interacted with the frame.试图导航顶级 window 的框架是跨域的或不受信任的,并且用户从未与该框架进行过交互。

What will be the work around for this problem as I don't have access to ABC.com and cookieless forms authentication seems huge change for us.由于我无法访问 ABC.com 和无 cookie forms 身份验证对我们来说,解决这个问题的方法是什么。

Is that possible to ask users to accept cookies from inside Iframe page and set cookies?是否可以要求用户从 Iframe 页面内部接受 cookies 并设置 cookies?

As solution we have done some changes to web.作为解决方案,我们对 web 进行了一些更改。 config配置

 <sessionState timeout="70" cookieless="AutoDetect" />

The possible values for "cookieless" attribute are: “cookieless”属性的可能值为:

AutoDetect : Session uses background cookie if cookies are enabled.自动检测:如果启用了 cookies,则 Session 使用后台 cookie。 If cookies are disabled, then the URL is used to store session information.如果 cookies 被禁用,则 URL 用于存储 session 信息。

UseCookie : Session always use background cookie. UseCookie : Session 始终使用后台 cookie。 This is default.这是默认设置。

UseDeviceProfile : Session uses background cookie if browser supports cookies else URL is used. UseDeviceProfile : Session 如果浏览器支持 cookies 则使用后台 cookie,否则使用 URL。

UseUri : Session always use URL. UseUri : Session 始终使用 URL。

And added:并补充说:

 <authentication mode="Forms">
      <forms loginUrl="Login.aspx" cookieless="AutoDetect" timeout="2880" name=".ASPXAUTH" slidingExpiration="true" />
 </authentication>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM