[Catalyst] how to do persistent session data (aka shopping cart) in catalyst?

Hernan Lopes hernanlopes at gmail.com
Thu Apr 26 14:49:37 GMT 2018


Dear Fernan Aguero,

On Thu, Apr 26, 2018 at 11:31 AM, Fernan Aguero <fernan.aguero at gmail.com>
wrote:

> Hello,
>
> what is the current recommended way of developing a persistent
> shopping-cart-style functionality in a catalyst app?
>
> We would like to be able to support the following:
> i) store session data in the server for logged in users
>

To store session data in the server you only need to identify your logged
in user and create the data on the server db.

ii) keep session data across sessions, and across browsers (e.g. computer
> at home, resume session using computer at work)
>

If you want to keep data across sessions and across browsers and across
computers, that means you must save data on the back end. ie create a table
with cart and cart_products.
Then when user creates a cart you assign it a user_id. That way when your
user logs in another computer you will able to load his cart.

iii) allow users to start working anonymously, then merge session data
> (shopping cart) smartly upon logging in
>

For this you need to create a cart on the database and associate it with a
user session cookie. then the user will associate multiple products into
his cart and your app will have to save that information on the database.
Then when the user signs up, your app will update the cart owner to your
user_id.


> Thanks for any pointer. Cheers,
>
> --
> fernan
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/
> catalyst at lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20180426/5d02d214/attachment.htm>


More information about the Catalyst mailing list