会话存储变量在登录时收到警告

时间:2017-12-19 04:56:31

标签: php session variables

我已在header.php

上存储了这样的会话值
$order_total = $_SESSION['order_total'];

每次登录时都会收到警告信息

  

注意:未定义的索引:order_total in   第15行的C:\ xampp \ htdocs \ zzz \ frontend \ header.php

一旦我再次访问该页面,该消息就被删除了

1 个答案:

答案 0 :(得分:0)

您必须先检查会话

session_start();

if(isset($_SESSION['order_total']) && !empty($_SESSION['order_total'])) {
   $order_total = $_SESSION['order_total'];
}else{
   $order_total = "session is not set";
}