[英]php fails to store any _SESSION or _GLOBALS variable
I am storing a session and a global variable in file1.php. 我在file1.php中存储一个会话和一个全局变量。 However, when I try to access those from file2.php I get nothing.
但是,当我尝试从file2.php访问那些文件时,我什么也没得到。 I am using php 5.1.6.
我正在使用PHP 5.1.6。
$_SESSION['abc'] = $a;
$GLOBALS['def'] = $b;
Any idea? 任何想法?
Thanks in advance. 提前致谢。
In regards to your edit: The variable stored in $GLOBALS is just a global to that script. 关于您的编辑:$ GLOBALS中存储的变量只是该脚本的全局变量。 You have to put the value in $_SESSION to use across pages.
您必须将值放在$ _SESSION中才能在页面之间使用。
Example: 例:
// Page 1
session_start();
$_SESSION['abc'] = "hello world";
$GLOBALS['def'] = "More stuff.";
// Page 2
session_start();
echo $_SESSION['abc']; // prints 'hello world'
echo $GLOBALS['def']; // is not defined. Globals aren't session variables.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.