图片验证码要使用session,如何能指定它的sessionid 很难的问题?没办法只好还是cookie based了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sid你自己定义的就要重载SESSION(set_session_handle),如果用php默认的PHPSESSID就可以直接用 session_start() 和session_id() 的关系如下情况1:session_start() 先运行,将由系统产生一个id,可用session_id()捕获情况2 :先运行 session_id(),再运行session_start(),这个id 由你控制情况2举例:$sess_id = randomstr(32) ; //randomstr是自己自定义的随机产生函数session_id($sess_id);session_start(); 确实,不过这个图片程序是否能接收某个指定的sessionid,产生的验证码放到一个随机的session里并不是我的初衷。 login.php<?phpsession_start();$PHPSSID = session_id();echo "<img src='yanzhengma.php?PHPSSID=$PHPSSID'>"; //生成验证码图片标签....yanzhengma.php<?php$PHPSSID = $_GET['PHPSSID'];session_id($PHPSSID);session_start();.....大多数情况下,php会自动完成这一动作。除非你在便宜php时少了 在session.use_cookie为1的时候正常,如果设为0就完了-------------------我设为0正常。不知道你怎么搞的<?php//$PHPSSID = randomstr(32);while(($PHPSSID=rand()%100000)<10000);session_id($PHPSSID);session_start();echo "<img src='img_yanzheng.php?PHPSSID=$PHPSSID'>"; //生成验证码图片标签?><?php //生成验证码图片 session_start(); Header("Content-type: image/png"); srand((double)microtime()*1000000); $im = imagecreate(620,20); $black = ImageColorAllocate($im, 0,0,0); $white = ImageColorAllocate($im, 255,255,255); $gray = ImageColorAllocate($im, 200,200,200); imagefill($im,0,0,$gray); while(($authnum=rand()%100000)<10000);$_SESSION["security_code"]=$authnum;$authnum = $_GET['PHPSSID'];//将整数验证码绘入图片 imagestring($im, 5, 10, 3, $authnum, $black); for($i=0;$i<200;$i++) //加入干扰象素 { $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagesetpixel($im, rand()%70 , rand()%30 , $randcolor); } ImagePNG($im); ImageDestroy($im);?> 数组位置替换,谁帮看看呗。 字符串替换的问题,请教高手 web 开发前景 有做过IFRAME弹窗的朋友吗 进来指点一下 PHP 如何读取word文档的内容? php 怎么把下列两个数组合并到一个数组里边去?? 谁知道PHPMyAdmin在另一个页面reload左框架页面的方式啊 之前还可以运行的程序,现在不行了 PHP配置中以前从未碰见过的问题 大家帮忙写个函数 php如何做日志记录? 高分请教一个正则表达式的问题
session_start() 先运行,将由系统产生一个id,可用session_id()捕获情况2 :
先运行 session_id(),再运行session_start(),这个id 由你控制
情况2举例:$sess_id = randomstr(32) ; //randomstr是自己自定义的随机产生函数
session_id($sess_id);
session_start();
<?php
session_start();
$PHPSSID = session_id();
echo "<img src='yanzhengma.php?PHPSSID=$PHPSSID'>"; //生成验证码图片标签
....yanzhengma.php
<?php
$PHPSSID = $_GET['PHPSSID'];
session_id($PHPSSID);
session_start();
.....大多数情况下,php会自动完成这一动作。除非你在便宜php时少了
-------------------
我设为0正常。不知道你怎么搞的
<?php
//$PHPSSID = randomstr(32);
while(($PHPSSID=rand()%100000)<10000);
session_id($PHPSSID);
session_start();
echo "<img src='img_yanzheng.php?PHPSSID=$PHPSSID'>"; //生成验证码图片标签?><?php
//生成验证码图片
session_start();
Header("Content-type: image/png");
srand((double)microtime()*1000000);
$im = imagecreate(620,20);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,0,0,$gray);
while(($authnum=rand()%100000)<10000);$_SESSION["security_code"]=$authnum;$authnum = $_GET['PHPSSID'];
//将整数验证码绘入图片
imagestring($im, 5, 10, 3, $authnum, $black); for($i=0;$i<200;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}
ImagePNG($im);
ImageDestroy($im);?>