0

I want to know best practice on how to create Shopping cart using MVC 5 Owin Identity with support anonymous users.

Example: So both logged in and anonymous user can select products. For logged in user all is ok, I have userId and can create cart for him. What I must do for anonymous user? How I can create cart for him?

Please help.

Vladimir Rodchenko
  • 1,052
  • 15
  • 25
  • I'm not really sure how OWIN or ASP.Net Identities factor into this, but an easy solution would be just to store someones cart items in session, then it wouldn't matter if they were logged in or not – mituw16 Mar 23 '15 at 16:40
  • First thing is why I don't want to user session is because http://brockallen.com/2012/04/07/think-twice-about-using-session-state. Also it is problem to integrate OWIN and session as they are working in different pipelines. – Vladimir Rodchenko Mar 23 '15 at 16:51
  • http://www.nsilverbullet.net/2014/06/24/tough-mvc-5-owin-external-authentication-issue/ describes problem with session – Vladimir Rodchenko Mar 23 '15 at 17:00

1 Answers1

1

Result of my investigation is so that it is bad to use Session with Owin & Identity.

http://brockallen.com/2012/04/07/think-twice-about-using-session-state http://www.nsilverbullet.net/2014/06/24/tough-mvc-5-owin-external-authentication-issue/

My variant is to create temp cookie for shopping cart with cartId. When user logging in I'm checking if cookie for shopping cart exists and if so I attach all files to user cart. In other case I'm taking user cart id to cookie if cart id exists.

Vladimir Rodchenko
  • 1,052
  • 15
  • 25