aguerradelgado / goodreads_webscraper_2

0 stars 0 forks source link

saving cart state in session #1

Closed aguerradelgado closed 1 year ago

aguerradelgado commented 1 year ago

this is the basic code i found online about the shopping cart in session, but I dont really know how to connect it to the button click and where to place this code either in index

create session object for our cart

session['tbr'] = [] ...

Since a mutable data type (list) is being modified, this change

is not automatically detected by the session object

session['tbr'].append('whatever was clicked on the tbr button')

Therefore, mark the session object as modified

session.modified = True probably have this in a loop? i dont really know

aguerradelgado commented 1 year ago

multiple ways that this can be done either with saving session information to database and making tbr a db view show * from book, join tbr on b_id where u_id = 'user id' (something like tbh my reasoning is a little wonky) with session objects above is session object pseudocode

aguerradelgado commented 1 year ago

this was completed using a session object for tbr cart, that was continuously appended to during the session based on the user