关于SESSION失效问题
时间:2007-11-04
来源:互联网
文件abc.php
经过编译后SESSION就失效。
不知道是PHP编译工具的原因还是zend的原因?
[ 本帖最后由 adleyliu 于 2007-11-4 11:31 编辑 ]
复制PHP内容到剪贴板
<?php
function abc()
{
if (!isset($_SESSION)) {
session_start();
}
session_destroy();
session_register('abc');
$_SESSION["abc"] = "123123";
return;
}
?>
文件:b.php
PHP代码:
<?php
function abc()
{
if (!isset($_SESSION)) {
session_start();
}
session_destroy();
session_register('abc');
$_SESSION["abc"] = "123123";
return;
}
?>
复制PHP内容到剪贴板
<?php
include('./abc.php');
abc();
echo $_SESSION['abc'];
?>
编译前可以正常输出:SESSION值:123123PHP代码:
<?php
include('./abc.php');
abc();
echo $_SESSION['abc'];
?>
经过编译后SESSION就失效。
不知道是PHP编译工具的原因还是zend的原因?
[ 本帖最后由 adleyliu 于 2007-11-4 11:31 编辑 ]
作者: adleyliu 发布时间: 2007-11-04
是否需要在程序最前面添加 session_start(); ?
作者: diekiss 发布时间: 2007-11-04
复制内容到剪贴板
session_start();
}
以上代码纯粹多于。应该在程序最前面添加 session_start();代码:
if (!isset($_SESSION)) {session_start();
}
Session variables: $_SESSION
Note: Introduced in 4.1.0. In earlier versions, use $HTTP_SESSION_VARS.
An associative array containing session variables available to the current script. See the Session functions documentation for more information on how this is used.
This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_SESSION; to access it within functions or methods, as you do with $HTTP_SESSION_VARS.
$HTTP_SESSION_VARS contains the same information, but is not a superglobal. (Note that $HTTP_SESSION_VARS and $_SESSION are different variables and that PHP handles them as such)
If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_SESSION and $HTTP_SESSION_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not superglobals.
作者: diekiss 发布时间: 2007-11-04
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28