php - PHP Session 不适用于某些(有时)移动用户?
问题描述
我正在为用户 orderid (siparisno) 创建会话,一些用户收到错误
“你没有订单号”。
使用 php7
//function1
//creating orderid(siparisno)
$rand1=rand(10,99);
$rand2=rand(10,99);
$rand3=rand(10,99);
$siparisno_manuel=date("dmy").strtotime("now").$rand1.$rand2.$rand3;
$siparisno=$siparisno_manuel;
$_SESSION["siparisno"]=$siparisno;
//function2
//getting orderid
@ob_start();
include __DIR__ . '/../view/success.php';
$buffer=@ob_get_clean();
$siparisno=$_SESSION["siparisno"];//GETTING HERE SESSION
if ($siparisno==null){
$string="<h3>Your order number could not be created. Please repeat your order.(error_code: $siparisno)</h3>";
$buffer=str_replace("{string}",$string,$buffer);
echo $buffer;
}else{
//create order with orderid
}
一些安卓用户得到
“无法创建您的订单号。请重复您的订单 (error_code:)”
用户:“Mozilla/5.0 (Linux; Android 8.0.0; SM-A520F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36”
解决方案
缺少 session_start() 页面顶部,如果您用于restapi,则无法将数据存储到会话,因为会话是无状态的......
seesion_start();
英吉利斯姆布卡达尔
推荐阅读
- sql - 根据多个真实条件查询所有相同的id
- reactjs - 无法在反应中更改标签
- java - Spring Boot/Java 的 LINQ 实现
- css - 使用 Wordpress 中的字体添加“预加载”
- wordpress - 如何在 Magento Docker 容器上持久化安装?
- node.js - 如何使用无服务器 AWS 进行跨应用程序
- angular - Angular 9 中未加载单个 spa 角度 i18n 文件
- javascript - 在运行时导入模块和导出
- swift-playground - Playground 导入 - 更新到 Xcode 12 后没有这样的模块
- c# - 从没有 DeserializeObject C# 的 Json 中获取值