【发布时间】:2025-11-22 14:05:01
【问题描述】:
我正在为用户 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()在哪里 -
您能否展示您的实际代码及其彼此之间的分离(您提到函数,函数定义在哪里,每个函数的调用方式和时间?)
-
小点
$siparisno=$siparisno_manuel; $_SESSION["siparisno"]=$siparisno;为什么中间变量,没用 -
不要忽略错误。它们很有用。
-
欢迎,为了改善您在 SO 上的体验,请阅读 how to ask 和 On Topic question,以及 Question Check list 和 the perfect question 以及最重要的是如何创建 @ 987654325@和take the tour