My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?
The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin
object that is assigned to current_user
. The assumption is that current_user
will not change throughout the session. However, I noticed that a new AnonymousUserMixin
object is assigned to current_user
, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated.
Any suggestions on how to circumvent this?