
iframe SameSite跨域问题处理
iframe SameSite跨域问题处理
解决方案一:
nginx里面反向代理加下面这句
proxy_cookie_path / "/; Secure; SameSite=NONE;";
解决方案二:
index.php
<html> <head> <title>cookie跨域</title> </head> <body> <iframe data-v-7197f682="" src="https://1234test.com:444/iframe.php" frameborder="0" style="width: 100%; height: 700px;"> </iframe> </body> </html>
iframe.php
<?php session_start(); $_SESSION['HAHAHAH'] = '213123123'; echo '<a href="https://1234test.com:444/show.php" >嵌套页</a>'; header('Set-Cookie:'.'PHPSESSID='.session_id().';Path=/;SameSite=None;Secure=false;');
show.php
<?php echo '显示session'; session_start(); var_dump($_SESSION);
这边iframe跨域的域名必须是https才行,否者配置无效,不会成功
原创文章转载请注明出处
iframe SameSite跨域问题处理