老是获取不得到值。于是造成老是无法正确判断session_id
别人的浏览器问题都没问题,就是我的机器有问题。后来这次换了新主机,新系统,问题又出现了,崩溃了。不知道是啥原因?
php生成验证码  myauth.php class auth{  
     public function auth()
      {
     session_start();                               //启动session
     $str="abcdefghijkmnpqrstuvwxyz23456789";   /*生成一个4位随机数  */
     for($i=0;$i<4;$i++){
                 $num.=substr($str,rand(0,29),1);
        }
      $_SESSION['code']=$num;   //将随机数保存到session中
      $im=imagecreate(60,25);    //创建一个60*20的图像
      $white=ImageColorAllocate($im,255,255,255);  //设置图像的背景色为白色
      $blue=ImageColorAllocate($im,0,0,255);   //设置图像中文本颜色为蓝色
      /* 将多个颜色不同的*号添加到图像中  */
      for($i=1;$i<200;$i++){
  $x=rand(1,60-9);
$y=rand(1,20-6);
$color=imagecolorallocate($im,rand(200,255),rand(200,255),rand(200,255));
imagechar($im,1,$x,$y,"*",$color);
}
/*将4位随机数添加到图像中,添加的位置不固定  */
   $strx=rand(3,8);
   for($i=0;$i<4;$i++){
$strpos=rand(1,6);
imagestring($im,5,$strx,$strpos,substr($num,$i,1),$blue);
$strx+=rand(8,12);
}
  header ("Content-type: image/gif");  //设置输出图像的格式
  imagegif($im);   //输出图像
  imagedestroy($im);  //释放图像资源
     //return $_SESSION['code'];
      exit;
    }
  }
  $auth = new  auth();
html显示<tr>
  <td style="color: white;">验证码:</td><td><span><input type="text" name="check"  id="check"/>
  <img id="img" onclick="refashImage()" src="{$baseurl}/auth.php" style="width:65px;height:20px;font-size:12px; vertical-align: middle;"  name="auth"/>
  </span></td><td><a style="font-size: 12px;color:white">点击图片刷新</a></td>
</tr>

解决方案 »

  1.   

    检查session.autostart是否开启了。
      

  2.   


    啥系统 那些山寨 ghost?
      

  3.   

    首先检查 检查session.autostart是否开启了
    不过 别人的浏览器都没问题,就是我的机器有问题。应该不是这个原因
    你得检查你的浏览器是否允许 cookie代码本身没有问题如果 html显示 src="{$baseurl}/auth.php"  那显然是不对的
    模板里这样还差不多
      

  4.   

    还有可能是路径这部分写错了<img id="img" onclick="refashImage()" src="<?php echo $baseurl;>/auth.php"... ;