我有一个非常奇怪的问题,PHP会话有时返回未定义的索引,但不是所有的时间。我不知道是否有人有类似的问题,我没有改变太多关于会话开始。我还检查了可用的磁盘空间,这似乎对会话数据很好。有人有过类似的经历吗?
<?php
session_start();
include_once "security_mobile.php";
include "session.php";
switch($var)
{
case "get_name":
echo $securitymob->get_name();
exit;
}
?>
Security_mobile.php
function get_name(){
return $_SESSION['customer']['name'];
}
这是第一个未定义发生在customer上的地方,然后它将不会在其他任何地方工作。但有时它确实有效,这就是困扰我的地方!
事件更新
我可以解决这个问题,只要我从我的应用程序中删除这个,但我需要得到这个工作。
connection.js
var getdb = Ti.Network.createHTTPClient({
onload : function(e) {
var response = this.responseText;
Ti.App.Properties.setString('tempDB', response);
},
onerror : function(e) {
failed(e);
},
timeout : 5000,
validatesSecureCertificate : false
});
getdb.open('POST', this.url, true);
getdb.send({
'action' : 'get_name',
'device' : 'mobile'
});
是否与返回$_SESSION['customer']['name']
有关,$_SESSION['customer']['name']
在Login阶段使用
答案是HTTP客户端请求发布得太快,这没有给连接和会话数据建立的时间,因此为什么结果是间歇性的。为了解决这个问题,我必须在第一个完成后执行下一个HTTP客户端。
https://stackoverflow.com/a/39877622/6371663