What is the right way to store data between pages in Sage - sessions or transients?

I’m build a site using Sage 9 which has a ‘wishlist’ feature where users can save items, a bit like a shopping cart but without any purchase option. There is no sensitive data being stored here, just a bunch of post ID’s. My goto approach would normally be to use a php session, but I am awaare that it could be done by setting a unique ID, dropping a cookie and creating a transient - which should I opt for? Is one way more ‘Sage’ than the other or does it not really matter??

Many thanks

Personally, I’d follow what WooCommerce does for their basket feature.

Info: https://docs.woocommerce.com/document/woocommerce-cookies/
Implementation: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Cart_Session.html#13-219

Reason I’d go this route is simply because WooCommerce is tried, tested, stable and most of the code IMO is good practice to follow (I’m sure there’s probably arguments against it though).

@codepuncher yeah was thinking of doing something similar, PHP sessions seem to be pretty much frowned upon and there are issues with caching! So dropping a cookie with a unique id via javascript then using that to name and retrieve a transient! But any other suggestions welcome!!!

This topic was automatically closed after 42 days. New replies are no longer allowed.