Anonymous user after putting some stuff into the cart and logs in before checkout looses all of the cart when authenticated.

The problem is with incorrect usage of session_id() in uc_cart.module. The login process regenerates the session id right before login in order to inhibit session fixation.

Below is a patch which resolves the issue with uc_cart.

(Also this was reported on the ubercart.org site: Anonymous user loses cart contents after login)

CommentFileSizeAuthor
uc_cart_session_id_replace-0.patch1.46 KBmtolmacs

Comments

rszrama’s picture

Will review... this needs to happen. fwiw, I haven't had any problems since the fix in UC 1.3 for the change in Drupal. I'm not sure how comprehensive the change should be for now, but if we're ditching the session ID we may as well turn the field into an integer in the DB... although, that might not be best since we want authenticated carts to persist indefinitely (based on uid).

Will have to think about it after the review...

mtolmacs’s picture

Using the session is fairly common to store the cart id in many webshop applications. For that matter, if you think about it the HTTP session concept was born to solve exactly such problems. The session holds data regarding the user who owns it. The cart (or its id as an abstraction of the cart) falls into this definition because it belongs to one and only one user.

The patch I sent simply replaces session id with a session variable which is managed exclusively by the developer, which is generally not true for the session id itself. The concept you created is still the same and valid in my opinion.

Island Usurper’s picture

Version: 5.x-1.3 » 6.x-2.x-dev
Status: Needs review » Fixed

Considering that this issue got broken again in Drupal 6 (#313570: Logging in empties cart), we decided to implement this in Ubercart 2.0. Since Drupal keeps track of the variables in $_SESSION without us needing to worry about the actual session id, this is a good solution, and probably what we should have done in the first place.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

john_wind’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

I have the latest (beta3) Ubercart installed (Drupal 6.6). No matter what settings I choose such as allow anonomys checkout, non logged in users click on a product and click "add to cart" and rather than going to the order process, the message is just (cart empty) with no other options? Please help. Thanks. --J

rszrama’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Support requests should be directed to the support forums. This sounds like a caching or missing UID 0 issue, and those are addressed by others in the forums. Also, the latest version is beta5. : )

GregoryHeller’s picture

i'm seeing this problem in 6.x.2.x-RC3

rszrama’s picture

Version: 6.x-2.x-dev » 6.x-2.0-rc3
Assigned: Unassigned » rszrama
Status: Closed (fixed) » Active
rszrama’s picture

Greg, I wasn't able to duplicate on my latest test site, http://amazon.commerceguys.com. Could you maybe give it a go there and put steps in here to reproduce the issue? It may be related to SSL or something, but I figured I'd try it on a vanilla site first.

GregoryHeller’s picture

i tried on your site and it works as you indicate. I followed all the same steps and it did not work on my site. I thought it might have something to do with uc_node_checkout other than that, i think the all of the same modules are involved on my site as your test site, though i am also using a class rather than the default product, and I am using attributes.

I created a normal product on my test site, with the default product content type, and no uc_node_checkout and tried, and i got the empty cart after login.

I also tried with no attributes and still same result.

any ideas on how else i could debug on my installation? or anything i should look at?

rszrama’s picture

Can you confirm your Drupal version? I know that somewhere along the line they changed the way the login form was working and I had to accommodate it.

GregoryHeller’s picture

Drupal 6.10 (will be upgrading shortly) and ubercart 6--2-rc3

GregoryHeller’s picture

we are no longer having this problem. In our case i thin kit was due to a trigger that sent the user to the home page after login, that and perhaps also related to the way we were adding data to the uc node checkout node.

Island Usurper’s picture

Status: Active » Closed (fixed)
viggy_prabhu’s picture

Issue tags: +anonymous, +login

yes, even I was facing the same problem but after I unassigned the trigger it was solved. Thanks Gregory Heller for mentioning the solution here.

agence web coheractio’s picture

Hi,

I'm having the same issue.
Could you please tell me which trigger is it and where I can unassign it ?

Thanks

Laurent

agence web coheractio’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active
agence web coheractio’s picture

Status: Active » Closed (fixed)

Found the bug : login restrict (submodule of domain access) is causing it.
When desactivated, ubercart works perfectly when registering users.
Laurent

robertoguzman’s picture

Version: 6.x-2.0-rc3 » 6.x-2.2

i have the same issue with ubercart 6.x-2.2 and drupal 6.17

waltercat’s picture

I'm having the same issue as well. I have the following options set:

user settings = Require e-mail verification when a visitor creates an account (unchecked)
user settings = Visitors can create accounts and no administrator approval is required. (checked)
Logintoboggan settings = Redirect path on registration: (blank)
Logintoboggan settings = Redirect path on confirmation: (blank)

Is there something else I am missing? When an anon user goes to checkout, he gets prompted for login on the login page. When registering he is sent to the homepage. When logging in he is sent to the user page. How do I make it so he is directed back to the checkout or cart?

zarudnyi’s picture

Status: Closed (fixed) » Active

I found that user loses contents if I check "Set password" option on Logintoboggan module settings page. Without that option all work fine.
Thanks.

tr’s picture

Priority: Critical » Normal
Status: Active » Closed (fixed)
zarudnyi’s picture

Status: Closed (fixed) » Active
rszrama’s picture

Assigned: rszrama » Unassigned
Status: Active » Closed (fixed)

aluminium, the reason TR closed the issue is because yours is not the same as the original post. I'm going to close this again and would request you to instead post a new issue with an appropriate title and full description of the problem you're experiencing. Thanks! : )

garyg’s picture

Happened to me too.
Disabled the "Login Destination" module and all is well.