Home > Backend Development > PHP Tutorial > session 丢掉

session 丢掉

WBOY
Release: 2016-06-13 12:10:48
Original
864 people have browsed it

session 丢失
在code里面我获取到验证码,代码如下

<br /><br />require 'ValidateCode.php';  //先把类包含进来,实际路径根据实际情况进行修改。  <br />$captcha = new Captcha(80, 30, 4);<br />$captcha->showImg();<br />$_SESSION['code'] = $captcha->getCaptcha(); //验证码保存到SESSION中  <br />
Copy after login


MVC结构,我在登陆的controller里面获取这个session
<br /><br /> var_dump($_SESSION['code']) ;<br />
Copy after login
,结果是NULL,这个事怎么回事,在入口文件index。php中,已经session——start了,php.ini里session也开启了,


新手求指教,谢谢
------解决思路----------------------
$_SESSION['code'] = $captcha->getCaptcha();
var_dump($_SESSION['code']) ;  //这行下面打印有不有值
------解决思路----------------------
如果已经有session_start();

那么可以输出$captcha->getCaptcha(); 看看是否为空。
------解决思路----------------------
a.php
session_start();
$_SESSION['test'] = '123';
?>

b.php
session_start();
echo $_SESSION['test'];
?>

先运行a.php ,然后运行b.php
看看是否有值。
------解决思路----------------------
看看Captcha::getCaptcha 的定义

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template