Move cart_entry to session

This commit is contained in:
Sijmen 2019-11-05 00:05:56 +01:00
parent 71b2d0a4e9
commit f9780b11be
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48
3 changed files with 2 additions and 7 deletions

View file

@ -51,9 +51,6 @@ run :-
:- persistent
session(session:atom, username:atom).
:- persistent
cart_entry(session:atom, items:atom).
:- json_object
error(error:atom).

View file

@ -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).

View file

@ -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'),