0
我目前使用下面的代碼作爲圖像驗證碼。圖像捕捉在iPhone上失敗,沒有會話數據可顯示
<?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);
?>
然後我用下面的驗證碼captch在提交表單的...
if (md5(addslashes($_POST['antispam'])) != $_SESSION['image_random_value']) {
我一直使用這個多年,它在瀏覽器中完美,但我剛認識它不適用於iPhone。
使用echo $ _SESSION ['image_random_value'];返回瀏覽器中的會話值,但在iphone上它返回一個空變量?
我累了改變了過期日期,並註釋掉了一些ref cache控件的參數。但這些都不起作用。 對於信息我也有我的iphone上啓用cookie。
任何提示或指向我錯過了什麼?