I have a problem with setting cookies in an iframe (which loads a site from another domain).
On my site X.COM I load <iframe src='Y.COM'>
我在iframe(从另一个域加载网站)中设置cookie时遇到问题。在我的网站X.COM上,我加载
Y.COM tries to set cookies, but Safari blocks they, as this site was not visited before. So loading Y.COM fails because it can't work without cookies. Is there a way to solve this issue?
Y.COM尝试设置cookie,但Safari会阻止它们,因为之前没有访问过这个站点。因此加载Y.COM失败,因为它没有cookie就无法工作。有没有办法解决这个问题?
P.S. I cann't modify any data at Y.COM.
附:我无法在Y.COM修改任何数据。
P.S.S. Also we can modify Safari's settings - "Accept cookies" = "Always"
, but it is not a solution for me - it seems to be impossible to lead every user to do it..
P.S.S.此外,我们可以修改Safari的设置 - “接受cookie”=“总是”,但它不是我的解决方案 - 似乎不可能引导每个用户这样做..
1 个解决方案
#1
4
I experimented a similar problem. A web "parent" page open my "child" website in a jquery fancybox i-frame cross-domain. Not problem at all with Explorer, Chrome, Firefox, Opera and even with Safari (5.8.1) on MAC. But with iPhone, iPad and mini iPad, the session in the i-frame is lost.
我尝试了类似的问题。一个网络“父”页面在jquery fancybox i-frame跨域中打开我的“子”网站。使用Explorer,Chrome,Firefox,Opera甚至在MAC上使用Safari(5.8.1)都没有问题。但是对于iPhone,iPad和迷你iPad,i-frame中的会话将丢失。
That's mean that at every click on an element in the i-frame (web site is in aspx) a new session started.
这意味着每次点击i-frame中的元素(网站都在aspx中)时,都会启动一个新会话。
We solve the problem in a very simple way:
我们以一种非常简单的方式解决问题:
when the parent website start, it call a page in the child site directly (not in an i-frame). In this page I just set a session variable and I redirect to the parent website. Now when the child website is open in an iframe, the session is kept.
当父网站启动时,它直接在子站点中调用页面(而不是在i帧中)。在这个页面中,我只设置了一个会话变量,然后重定向到父网站。现在,当子网站在iframe中打开时,将保留会话。
#1
4
I experimented a similar problem. A web "parent" page open my "child" website in a jquery fancybox i-frame cross-domain. Not problem at all with Explorer, Chrome, Firefox, Opera and even with Safari (5.8.1) on MAC. But with iPhone, iPad and mini iPad, the session in the i-frame is lost.
我尝试了类似的问题。一个网络“父”页面在jquery fancybox i-frame跨域中打开我的“子”网站。使用Explorer,Chrome,Firefox,Opera甚至在MAC上使用Safari(5.8.1)都没有问题。但是对于iPhone,iPad和迷你iPad,i-frame中的会话将丢失。
That's mean that at every click on an element in the i-frame (web site is in aspx) a new session started.
这意味着每次点击i-frame中的元素(网站都在aspx中)时,都会启动一个新会话。
We solve the problem in a very simple way:
我们以一种非常简单的方式解决问题:
when the parent website start, it call a page in the child site directly (not in an i-frame). In this page I just set a session variable and I redirect to the parent website. Now when the child website is open in an iframe, the session is kept.
当父网站启动时,它直接在子站点中调用页面(而不是在i帧中)。在这个页面中,我只设置了一个会话变量,然后重定向到父网站。现在,当子网站在iframe中打开时,将保留会话。