php - 为什么我的 $_SESSION 会在文件之间丢失多维数组数据?
问题描述
我确信我的问题确实来自于不了解一个非常基本的机制,但我已经花了几个小时,但我仍然无法解决问题。
我做了两个测试文件:test1.php:
//as you can see I did some research, yet it looks that my session save path is fine, so this is not the case
if (is_writable(session_save_path()))
echo 'ok <br />';
$_SESSION['test'] = '!!!single!!!'; //this saves and stays in the $_SESSION
$_SESSION[1]['test'] = '???multi???'; //this dissapears - but why and how to prevent this?
print_r($_SESSION);
?>
结果:
ok 数组 ( [test] => !!!single!!! [1] => Array ( [test] => ???multi??? ) )
完全符合预期。
测试2.php:
if (is_writable(session_save_path()))
echo 'ok <br />'; //just to be sure
print_r($_SESSION); //why, oh why?
?>
结果:
好的数组( [test] => !!!single!!! )
而我的“[1] => Array ([test] => ???multi??? )” 不存在...但是为什么呢?超全局 $_SESSION 设置如上,没有任何改变......
我的服务器确实将 register_globals 设置为关闭 - 好吧,可能是这种情况吗?即使-我不想就那样打开它。无论如何,这似乎是错误的事情。
非常感谢提前,最好的问候!
解决方案
推荐阅读
- reactjs - 如何使用 reactJS 打印当前日期和时间
- python - 为什么在我的 IDLE 上导入 Tensorflow 会导致错误?
- javascript - 在 VSCode 中运行 Flask 项目时如何调试 javascript 文件?
- react-native - 带有 Sticky 视图的 ScrollView 位于状态栏下方
- python - Machine Learning Tools Docker Image Size Issue
- avalonia - FrameworkPropertyMetadataOptions.AffectsMeasure and FrameworkPropertyMetadataOptions.AffectsRender in Avalonia
- reactjs - React.js - understanding hooks and their rules
- html - 转发特定时间的网页
- amazon-web-services - AWS 自定义域名映射 - 缓存?
- azure - 为 Azure Functions 安装 powershell 模块不起作用