对于 IE,您将需要 P3P 标头集。就像是:
<?php header('P3P: CP="CAO PSA OUR"'); ?>
默认情况下,Safari 会阻止 3rd-party cookie。目前,唯一对我有用的解决方法是“弹出”一个新窗口来设置 cookie。我有这样的事情:
<script type="text/javascript">
function safariFix(){
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){
window.open('https://yourdomainname.com/safari.php', 'Safari Fix','width=100,height=100');
}
}
</script>
safari.php会有这个:
<?php
setcookie("safari_test", "1");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Safari Fix</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
window.close();
});
</script>
<body>
Since Safari does not accept third-party cookies by default, we are forced to open this window.
This window will automatically close once we have set the cookies.
</body>
</html>
问题:如果用户在 Safari 中启用了“阻止弹出窗口”,这将不起作用。如果有人对此有更好的解决方案,请告诉我;)