現在、次のコードを画像キャプチャとして使用しています。
<?php
session_start();
$alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
// generate the verication code
$rand = substr(str_shuffle($alphanum), 0, 5);
// choose one of four background images
$bgNum = rand(1, 4);
$image = imagecreatefromjpeg("background$bgNum.jpg");
$textColor = imagecolorallocate ($image, 0, 0, 0);
// create the hash for the random number and put it in the session
$_SESSION['image_random_value'] = md5($rand);
// write the random number
imagestring ($image, 15, 50, 10, $rand, $textColor);
// Date in the past
header("Expires: Mon, 23 January 2009 01:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/jpeg');
// send the image to the browser
imagejpeg($image);
// destroy the image to free up the memory
imagedestroy($image);
?>
次に、以下を使用して、フォームの送信でキャプチャ コードを検証します...
if (md5(addslashes($_POST['antispam'])) != $_SESSION['image_random_value']) {
私はこれを何年も使用しており、ブラウザでは完璧に動作しますが、Iphone では動作しないことに気付きました.
echo $_SESSION['image_random_value']; の使用 ブラウザではセッション値を返しますが、iphone では空の変数を返しますか?
有効期限を変更したり、いくつかのパラメーター ref キャッシュ コントロールをコメントアウトしたりするのにうんざりしています。しかし、これはどれも機能しません。また、iPhone で Cookie を有効にしています。
私が見逃したものへのヒントや指針はありますか?