Permalink
Browse files

cookie5 : 쇼핑몰 장바구니 기능 4

  • Loading branch information...
egoing committed Mar 25, 2016
1 parent 2c8eee6 commit 89934e99983be11f46625e2083608179354d1f89
Showing with 17 additions and 0 deletions.
  1. +17 −0 app_cookie.js
View
@@ -30,6 +30,23 @@ app.get('/cart/:id', function(req, res){
res.cookie('cart', cart);
res.redirect('/cart');
});
app.get('/cart', function(req, res){
var cart = req.cookies.cart;
if(!cart) {
res.rend('Empty!');
} else {
var output = '';
for(var id in cart){
output += `<li>${products[id].title} (${cart[id]})</li>`;
}
}
res.send(`
<h1>Cart</h1>
<ul>${output}</ul>
<a href="/products">Products List</a>
`);
});
app.get('/count', function(req, res){
if(req.cookies.count){
var count = parseInt(req.cookies.count);

0 comments on commit 89934e9

Please sign in to comment.