【已解决】求解Zend Framework的session问题
本帖最后由 craaazy123 于 2013-07-15 15:52 编辑我验证码模块Controller:
class CaptchaController extends Zend_Controller_Action {
public function getAction() {
$this->render('captcha');
}
public function verifyAction() {
session_start(); //忘记加这玩意了{:3_186:}
$vcode = $this->getRequest()->getParam('vcode');
echo $vcode;
echo '<pre>';
var_dump($_SESSION);
echo '</pre>';
exit();
}
}
views/captcha/captcha.phtml中,为了突出重点,省略生成图片的代码:
session_start();
header("Content-type: image/gif");
$_SESSION['code'] = strtolower($code);
//输出gif格式图片
imagegif($img);
//销毁图片资源
imagedestroy($img);
访问http://domain.com/captcha/get能获取到验证码图片,
但是不能在verifyAction中获取到$_SESSION['code']的值,var_dump($_SESSION)输出为NULL(确定是在浏览器同一session中,cookie没有关掉)
接触php不久,有谁知道原因的帮我一下,在此谢过了
页:
[1]