<?php
if(!isset($_SESSION)){
  session_start();
}
require_once("ImageCode.php");
unset($_SESSION['yzm']);
$randCode = '';
$chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ23456789';
for ( $i = 0; $i < 4; $i++ )
{
  $randCode .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
$_SESSION['yzm']=$randCode;     // 记录session
ImageCode($randCode);
 
/*方法二*/
/*$authstr = mt_rand(1000, 9999);  // 生成随机字符串
$_SESSION['yzm'] = $authstr;  // 记录session
ImageCode($authstr, 60);  // 显示GIF动画*/
?>
