사용자가 정보 세션을 로그 아웃 할 때 $ _SESSION [ "info"] 및 $ _SESSION [ "cart"] 배열을 저장하는 세션이 있으므로 unset ($ _ SESSION [ info "]하지만 장바구니 세션은 유지됩니다. 정보 세션은 사용자의 ID를 저장합니다. 이제 정보 배열에서 해당 사용자의 ID를 검색하고 사용자가 로그 아웃 할 때이를 쿠키에 저장하려고합니다. 따라서 사용자가 다시 로그인 할 때 . 세션에 저장되어있는 사용자 ID가 쿠키의 사용자 ID와 일치하는 경우 그 사용자 ID에 관련된 카트 배열을 사용하여,에특정 배열을 쿠키에 저장하십시오.
이 내 logout.php에서 지금까지 무엇을 가지고 :에서
$_COOKIE["userID"] = $_SESSION["info"]["id"];
unset($_SESSION["info"]);
내 소원 ist.phtml :
<?php
if (isset($_SESSION["cart"])) {
if (count($_SESSION["cart"])>0) {
echo '<br><br>';
echo '<table class="table table-hover"><thead><tr>';
echo '<th>Owner</th><th>Car</th><th>Price</th><th class="text-center">Action</th> </tr>';
echo '</thead><tbody>';
foreach ($_SESSION["cart"] as $key => $wish) {
echo '<tr><td>' . $wish["username"]. '</td><td>' . $wish["car"]. '</td><td>' .$wish["price"]. '</td><td class="text-center"><a href="/removecar.php?car='.$key. '"><button id="view" type="button" class="btn btn-danger">x</button></a></td></tr>';
}
echo '</tbody></table>';
}
else {
echo '<div class="alert alert-danger">You do not have any cars in your wishlist.</div>';
};
}
?>
누구에게 내가 어떻게해야하는지 알고 있습니까?