| Project: | Ubercart Contributions |
| Component: | Code |
| Category: | |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Know that you were working on this, but it's still happening. Shop, then cart, then login, then all gone!
|
Ubercart |
|
|
|
||
I just like to mention that I am experiencing the same. Right now I am testing Übercart 1.3 with Drupal 5.9 and ... same here. As an anonymous user you will loose your cart content when logging in. Maybe you could give me a short explanation why this happens?
Strange. My setup is the following: Drupal 5.10 (lastest maintenance release), UC 1.3 RC1. Anonymous checkout disabled. Administrators have to approve new user accounts first. The senario is the following: As an anonymous user, I put something in the shopping cart and click "checkout". I register for a new account. The next page that says "Thank you for applying for an account. Your account is currently pending ..." says also "There are no products in your shopping cart...". Next scenario: as an anonymous user I put something in my cart, click "Checkout", login as an registered user, next page says "Your shopping cart is empty". I came up with the idea that this behaviour might have something to do with session handling. I got the following information from the Devel module: As anonymous user, when I have put something in my cart, session viewer says: Array After checking in: As you can see, the session ID has been changed after loggin in. Is that the proper behaviour? You mentioned something about an issue with Drupal 5.8 / 5.9. Could you give me some more details. Maybe I will able to solve this out by myself. Thanks! ps. you've done a great job with UC! I am still a newbie when it comes to Drupal / UC, but I have been coding PHP for production sites for about 5 years now. ds.
Hmm... you know, I think I actually ran into this with a client, and the recourse at the time was to simply disable account validation. I tend to think it should work without having to resort to that, but I'd honestly recommend it for conversion purposes anyways (unless you just really really need account moderation). Also, it may be a bug that got massaged out in the actual 1.3 release (the one after RC1). Thanks for your kind words. EDIT: Looking at the source, the offending function is uc_cart_user() in uc_cart.module. I do believe you're right about the session rebuilding... if the user was to login at the time they created the account, the cart should be updated no problem. Honestly, I think a good solution moving forward would be to not use the session ID but actually have a cart ID session variable. Seems like a no brainer.
After digging into the code a little bit deeper, I now think I am on to something. I think that this issue has nothing to do with UC, rather with the fact how Drupal handels user sessions. Especially session handling when a anonymous user loggs in (and viceversa). I think that this thread (http://drupal.org/node/280934) might have something to do with it. Commenting out 'session_regenerate_id () form the following code actually overcomes the issue: -- from session.inc in the Drupal core include files --- /** // We code around http://bugs.php.net/bug.php?id=32802 by destroying //session_regenerate_id(); //db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id); But, I am not quite sure yet how this affects other modules or Drupal core functions.
You shouldn't comment out session_regenerate_id because you'll risk session fixation attack against your site. The problem easily can be circumvented by using your own session variable to store the cart id. The permanent session id is not something you can rely on and you shouldn't have.
Odly, even though this ticket on d.o is closed i am still having this problem in drupal 6 with Ubercart 6.x.2.0-RC3, an anon user is prompted to "click here to login with an existing account and return to checkout". and when they do, their cart which previously had some number of products in it, is empty after login.
I submitted this on another thread, but thought that posting it here might be useful also: I have a similar problem, but in my case if the anon user adds items to their cart before logging in and then decides to login from the checkout page, their cart is updated with the same items again. I am using the Discount module, so after they login our 'member discounts' are applied. Wondering if this is the cause? UPDATE:
...I worked about it by going to admin/user/settings and disabling (uncehecking) "Require e-mail verification when a visitor creates an account". After that change, Anon users can Add to Cart, Create New Account, and are automatically returned to the Checkout (/cart/checkout) page. (at top of the Checkout page is a token message which says "Registration successful. You are now logged in."). Ideally, I'd like to require email verification, but can live without it for now. Good luck!
I am facing the same problem. I am facing it even for registered user who login when they are directed to login page. Could you please tell me the solution for it. ubercart version == 6.x-2.0-beta4 the trigger to take user to home page after login was causing the problem. After I unassigned it, the problem was solved. I found the solution here, http://drupal.org/node/305177 |
|
Actually... I was unaware of any remaining issues. Are you running the latest Drupal/Ubercart? There was an issue in the updates from Drupal 5.8-5.9 that affected this, but it should've been fixed in UC 1.3.