From f9780b11be76977100a6a3166ae500d6eb1ec752 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Tue, 5 Nov 2019 00:05:56 +0100 Subject: [PATCH] Move cart_entry to session --- main.pl | 3 --- views/cart.pl | 3 +-- views/products.pl | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/main.pl b/main.pl index d847a83..45e3758 100644 --- a/main.pl +++ b/main.pl @@ -51,9 +51,6 @@ run :- :- persistent session(session:atom, username:atom). -:- persistent - cart_entry(session:atom, items:atom). - :- json_object error(error:atom). diff --git a/views/cart.pl b/views/cart.pl index c4a38eb..7edca7c 100644 --- a/views/cart.pl +++ b/views/cart.pl @@ -6,7 +6,6 @@ cart_add(ProductName, Request) :- http_redirect(see_other, root(.), Request). cart_add(ProductName, Request) :- - http_session_id(SessionId), - assert_cart_entry(SessionId, ProductName), + http_session_assert(cart_entry(ProductName)), http_redirect(see_other, root(.), Request). diff --git a/views/products.pl b/views/products.pl index 1b1bf88..886113c 100644 --- a/views/products.pl +++ b/views/products.pl @@ -78,9 +78,8 @@ account --> html(a(href('/login'), 'Log in')). products_view(get, _Request) :- - http_session_id(SessionId), (bagof(product(X, Y), product(X, Y), Products); Products = []), - (bagof(Name, cart_entry(SessionId, Name), CartEntries); CartEntries = []), + (bagof(Name, http_session_data(cart_entry(Name)), CartEntries); CartEntries = []), reply_html_page( [ title('point of shit'),