function setCookie(){
if ( navigator.userAgent.indexOf('Safari') != -1 &&
navigator.userAgent.indexOf('Chrome') == -1 ){
window.open('safari.php','','width=200,height=100' );
}
}
// then we set the cookie in safari.php
ソース: http://www.reizbombardement.de/archives/safari-5-1-4-enforces-cookie-policy
//2013 年 7 月 23 日更新
この問題を修正するこのくだらない方法は、Safari 6 まで機能していました。
以下の @Fabio Antunes と @ncubica のコメントをご覧ください。
//更新 2013 年 7 月 23 日 Fabio Antunes
これが私のコードです
ランディング ページには、アプリに関する簡単な説明と、「入力」などのボタンがあります。jquery を使用してこのプロセスを簡素化し、クリック イベントのリスナーを作成しています。ランディング ページの残りの html コードが既にあると想定しているため、javascript コードのみを配置します。
$(document).on("click", "#bt-landing", function(){
var left = (screen.width/2)-(500/2);
var top = (screen.height/2)-(250/2);
window.open('URL_FOR_THE_PHP_THAT_WILL_CREATE_THE_SESSION', '_blank', 'width=500,height=250,toolbar=0,location=0,menubar=0, top='+top+', left='+left);
});
これにより、画面の中央に 500 x 250 ピクセルの小さなウィンドウが開きます。
小さなウィンドウ用のコードは次のとおりです。
<?php setcookie("safari_cookie", "1");?>
<html>
<head>
<meta charset="utf-8">
<title>THE NAME OF YOUR APP OR SOMETHING THAT THE USER WE'LL READ AND ASSUME THAT THIS SMALL WINDOW IS RELIABLE</title>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
setTimeout(function(){window.close()},1000);
})
</script>
</body>
</html