Mailing List Archive

how to do persistent session data (aka shopping cart) in catalyst?
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
ii) keep session data across sessions, and across browsers (e.g. computer
at home, resume session using computer at work)
iii) allow users to start working anonymously, then merge session data
(shopping cart) smartly upon logging in

Thanks for any pointer. Cheers,

--
fernan
Re: how to do persistent session data (aka shopping cart) in catalyst? [ In reply to ]
Dear Fernan Aguero,

On Thu, Apr 26, 2018 at 11:31 AM, Fernan Aguero <fernan.aguero@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@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/
> catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
Re: how to do persistent session data (aka shopping cart) in catalyst? [ In reply to ]
Hi Fernan,

The I did for a small/medium size enterprise it was:

- Cart data is stored at DB level, so the information can be replicated
among all devices and browsers sessions.
- If an Anonymous user has cart data and then log in, then merge
previous stored cart with the new cart (business rules apply here).

It wasn't difficult to implement using the already available catalyst
plugins and, if needed, JSON serialization.

Good luck!


2018-04-26 11:31 GMT-03:00 Fernan Aguero <fernan.aguero@gmail.com>:

> 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
> ii) keep session data across sessions, and across browsers (e.g. computer
> at home, resume session using computer at work)
> iii) allow users to start working anonymously, then merge session data
> (shopping cart) smartly upon logging in
>
> Thanks for any pointer. Cheers,
>
> --
> fernan
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/
> catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
Re: how to do persistent session data (aka shopping cart) in catalyst? [ In reply to ]
Thanks for all the responses.

So, it's just a matter of using standard Catalyst::Plugin:Session, and
maybe also Catalyst::Plugin::Session::Store::DBIC and then write some
business logic to either use the session_data from the sessions table
(anonymous user) or the session_data from the users table (logged in user)?
I'd appreciate if you can share more details on the implementations
(plugins you use/recommend?)

I'm asking because we used to have an old catalyst app relying on
Catalyst-Plugin-Session-PerUser for this, but it's currently broken. It
used to work well with the older (deprecated) Authentication::Store::DBIC,
but switching to the current Catalyst-Authentication-Store-DBIx-Class
breaks it.

Anyway, I assume that so far, with the info we have, we will have to
rewrite the logic within Catalyst-Plugin-Session-PerUser in our app.

Cheers,

--
fernan

On Thu, Apr 26, 2018 at 11:54 AM, Hector Azpurua <h3ct0r.ml@gmail.com>
wrote:

> Hi Fernan,
>
> The I did for a small/medium size enterprise it was:
>
> - Cart data is stored at DB level, so the information can be
> replicated among all devices and browsers sessions.
> - If an Anonymous user has cart data and then log in, then merge
> previous stored cart with the new cart (business rules apply here).
>
> It wasn't difficult to implement using the already available catalyst
> plugins and, if needed, JSON serialization.
>
> Good luck!
>
>
> 2018-04-26 11:31 GMT-03:00 Fernan Aguero <fernan.aguero@gmail.com>:
>
>> 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
>> ii) keep session data across sessions, and across browsers (e.g. computer
>> at home, resume session using computer at work)
>> iii) allow users to start working anonymously, then merge session data
>> (shopping cart) smartly upon logging in
>>
>> Thanks for any pointer. Cheers,
>>
>> --
>> fernan
>>
>> _______________________________________________
>> List: Catalyst@lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/ca
>> talyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>>
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/
> catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>


--
fernan