I'm working on something similar to a shopping cart basket. I am dropping items into an array that is stored in a session. I then write to and get data from a table at key times. Everything is working well until a user adds items to the basket, then logs into the website. All data is still in session, but I have no event to move data to the database, so the data is lost when logging out.
I have seen posts about pre and post hooks used with the login module, but this is something I hope to use on some other sites and it would be nice to have something I can drop in to use without having to go through a bunch of setup steps. Is there an event that fires when the session changes I can capture to transfer the data from the session to the database?
[ed. note: insomnix last edited this post 14 years, 6 months ago.]
I posted this a while back and went on to work on something else. I'm now back to working on this part. In that time I have learned more about plugins and how they work and I think what I need is a plugin using the weblogin event to transfer my session data to a table.
Anyone out there have a better idea? If not, anyone have a good example of how I should do this?
-
MODX Staff
- 10,725 Posts
I would a) store the cart data in a cookie outside of the session before a user logs in and b) copy that data to the session once they log in.