Move cart_entry to session
This commit is contained in:
parent
71b2d0a4e9
commit
f9780b11be
3 changed files with 2 additions and 7 deletions
3
main.pl
3
main.pl
|
@ -51,9 +51,6 @@ run :-
|
||||||
:- persistent
|
:- persistent
|
||||||
session(session:atom, username:atom).
|
session(session:atom, username:atom).
|
||||||
|
|
||||||
:- persistent
|
|
||||||
cart_entry(session:atom, items:atom).
|
|
||||||
|
|
||||||
:- json_object
|
:- json_object
|
||||||
error(error:atom).
|
error(error:atom).
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ cart_add(ProductName, Request) :-
|
||||||
http_redirect(see_other, root(.), Request).
|
http_redirect(see_other, root(.), Request).
|
||||||
|
|
||||||
cart_add(ProductName, Request) :-
|
cart_add(ProductName, Request) :-
|
||||||
http_session_id(SessionId),
|
http_session_assert(cart_entry(ProductName)),
|
||||||
assert_cart_entry(SessionId, ProductName),
|
|
||||||
http_redirect(see_other, root(.), Request).
|
http_redirect(see_other, root(.), Request).
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,8 @@ account -->
|
||||||
html(a(href('/login'), 'Log in')).
|
html(a(href('/login'), 'Log in')).
|
||||||
|
|
||||||
products_view(get, _Request) :-
|
products_view(get, _Request) :-
|
||||||
http_session_id(SessionId),
|
|
||||||
(bagof(product(X, Y), product(X, Y), Products); Products = []),
|
(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(
|
reply_html_page(
|
||||||
[
|
[
|
||||||
title('point of shit'),
|
title('point of shit'),
|
||||||
|
|
Loading…
Reference in a new issue