I'm trying to redirect to a page using the following window.location to another page however the data inside the browser's localStorage is being deleted. I'm storing the data by using JSON stringify to an array:
function replaceCartStorage(arr){
if(arr.length==0){
localStorage.removeItem("cart");
window.location = "http://localhost/cw2/Basket.html";
}else{
localStorage["cart"] = JSON.stringify(arr);
window.location = "http://localhost/cw2/Basket.html";
}
}