我的代码在本地服务器上运行良好,但在实时服务器上无法运行。
我的本地服务器是 WAMP,而实时服务器是带有 LiteSpeed、PHP 和 MySQL 的 Unix。
问题是我希望仅在不存在时才创建新会话。请问有人可以帮忙吗?
确切的代码如下:
$cart = $_SESSION["cart"];
if (isset($cart))// this checks if session has been created already.
$cart = $cart; // if session is already set, it uses the random value already created.
else {
$_SESSION["cart"] = rand(111111111,999999999);// if session has not be created before a new randome number is picked.
$cart = $_SESSION["cart"];
}