This discussion is archived
6 Replies Latest reply: Oct 7, 2013 9:19 PM by Rajeev_R RSS

Using Cookies for both Anonymous and Login users carts

boyd4715 Newbie
Currently Being Moderated


Have a request so that all carts are managed via cookies until they are submitted as orders.

 

So, for the ShoppingCart.properties I have set the following:

 

# Settings for persisting shoppingCart
persistOrders=false

# Setting for persisting shopping cart of anonymous users
persistOrdersForAnonymousUsers=false

 

Here are the problems that I am facing with the above change:

  1. As an anonymous user, if I close the tab and reopen the tab, navigate to the site, my cart is populated with the previous items but, if I exit the browser and navigate back to the site, the cart is empty.
  2. As a Logged in user, I am seeing the same behavior
  3. I also see that if I am logged in and have an item in my cart and then log out, the cart is empty where as if I start off as an anonymous and then switch to the logged in user the cart remains populated

 

So the question is - is it possible to have both Anonymous and logged in users use cookies when dealing with carts and only persist orders when submitted?

  • 1. Re: Using Cookies for both Anonymous and Login users carts
    RajeshKDuraisamy Newbie
    Currently Being Moderated

    It is working as expected . it is not saving any data in profile for both logged in user and anonymous user as you disabled it .

    Please explain what is the expected behavior .

     

    Cheers ,

    Rajesh

  • 2. Re: Using Cookies for both Anonymous and Login users carts
    boyd4715 Newbie
    Currently Being Moderated

    Rajesh,

     

    Correct that is the expected behavior.  The behavior that is in question is to why the cart is not being retrieved from the cookie when either the anonymous or logged in user returns back to the site.  See my comments concerning the behavior with respect to the different browsers.  It has also been reported by some of our testers to happen intermittently.

     

    Any direction as to why this would occur or places to look at.

     

    Before I made the change - there was no reported issues for anonymous users when their cart was saved to the cookie.

     

    Here is what I have in the cookiemanger.properties

     

    # @version $Id: //hosting-blueprint/B2CBlueprint/version/10.0.2/EStore/config/atg/userprofiling/CookieManager.properties#2 $$Change: 635969 $
    $class=com.vsg.userprofiling.SCVLCookieManager


    # Enable sending of profile cookie
    sendProfileCookies=true

     

    # Persist cookie for 15 days (60 * 60 * 24) * 15 = seconds
    profileCookieMaxAge=1296000
    recentlyViewedCookieAge=1296000

     

    # Cookie hashkey
    # cookieHashKey=

     

  • 3. Re: Using Cookies for both Anonymous and Login users carts
    RajeshKDuraisamy Newbie
    Currently Being Moderated

    Do you have any logic to retrieve the order from cookie and saving it to profile during post login or session authentication .

     

    Cheers,

    Rajesh

  • 4. Re: Using Cookies for both Anonymous and Login users carts
    boyd4715 Newbie
    Currently Being Moderated

    We have some overridden methods for postLogin* but they all call upon super to do the majority of the work.  The overridden methods are checking for some promos that might be left over on the user profile that need to be removed - nothing to big.

     

    Are there other areas of the code that would cause this behavior - that is not pulling an abandoned cart from the cookie for either an anonymous or login user?

  • 5. Re: Using Cookies for both Anonymous and Login users carts
    boyd4715 Newbie
    Currently Being Moderated

    So I may have been some what confused on the expected behavior - so let me state my understanding and let me know if it is correct or not with regard to ATG, Cookies, Session, orders and normal browser behavior.

     

    Use case 1:  persist orders for logined in users

     

    persistOrdersForAnonymousUsers=false

    persistOrders=true

     

    A logged in user will have their cart persisted to the database.  So in the event the user does not complete an order, and either the session expires or closes the browser, when the user returns to the site the cart will be repopulated by the order id and profile id referenced in the cookie.

     

    For anonymous users - no orders will be saved to the database (unless they are complete/submitted orders)  So in the event the user does not complete an order, and either the session expires or closes the browser, when the user returns to the site the cart will be empty.

     

    Closing a tab in a multiple tab browser session will not kill the session - therefore if an anonymous user reopens the tab before session expiration, the cart will still be populated as the order is saved in the session.

     

    Use Case 2:  Do not persist order for logged in users.

     

    persistOrdersForAnonymousUsers=false

    persistOrders=false

     

    For logged in user - no orders will be saved to the database (unless they are complete/submitted orders).  So in the event the user does not complete an order, and either the session expires or closes the browser, when the user returns to the site the cart will be empty.

     

    No change between Use Case 1 and Use Case 2 for anonymous users.

  • 6. Re: Using Cookies for both Anonymous and Login users carts
    Rajeev_R Journeyer
    Currently Being Moderated

    The above understanding of yours is correct. In ATG OOB, it never stores any details related to order in a cookie. What it stores is just the profile id. If you want to enable a cookie based authentication or retrieves the order based on cookie, you have to persist the anonymous profiles and persist the orders for anonymous users as well.

     

    When a session starts, ATG will check for profile cookie and load the order based on that. Note that the OOTB transient profile will not function correctly now, you need to trust the Profile.securityStatus property here; there is a designated value for cookie based authentication.

     

    Cheers

    R

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points