Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:17:06+00:00 2026-06-11T17:17:06+00:00

I might be approaching the problem from the wrong point of view so please

  • 0

I might be approaching the problem from the wrong point of view so please correct me if my technique is wrong.

I’m creating guest users on a website with php. When someone visits the website, a guest user is automatically created. But if that person logs into a “normal” account (non guest) then whatever that person did in the guest account is transferred to the new account.

Example, someone visits a website without authenticating, add products from the shop in his cart and then logs in. I will need to transfer the cart items from the old user (guest) to the new user.

But it would be too time consuming (and possibly too resource hungry) to find every item in every table that is linked to the guest user account and then change them all. Right?

But I’ve got constraints! Yay! If I update the guest user id, all the constraints change. Fabulous! But what if I need to assign them to another user id? How would I do that?

Any help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:17:07+00:00Added an answer on June 11, 2026 at 5:17 pm

    You can’t do exactly what you’re suggesting because the user row (for the logged in user) presumably already exists. The only option would be to go through each table and update the UserID there, like you suggest. The feasability of this depends on what they can do as a guest user. If it’s only one or two tables, just do it this way.

    But, every problem can always be solved by another layer of abstraction, right? Put another single table (I’ll call it “pseudousers”) in between the real users table and everything else. Link everything else to this new table, and use the “psuedousers” to link up to the users table. When the guest user logs in, just change the UserID in the pseudousers table and you’re done.

    What I mean is:

    +---------+    +-----------+    +-------+
    | Users   |----|Pseudousers|----| Carts |
    +---------+    +-----------+    +-------+
                       |            
                       |            +-------+
                       |------------| ...   |
                                    +-------+
    

    When you create a guest user, you create a new row in Users and Pseudousers. When they log in, update the UserID in Pseudousers to point to that user, and then you can safely delete the guest user row in Users (it’s no longer in use).

    Hopefully someone can come up with a better name than “Pseudousers” though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I might be approaching this problem completely wrong, but I'm still a bit new
I might be approaching this the wrong way, but I'd like to have an
I might be approaching this all wrong but... I have a linux kernel device
I think I might be approaching this in the wrong way, so I would
What are the steps that you follow when approaching a problem statement, which needs
I might be doing this wrong overall, but maybe someone will be able to
Might seem like a stupid question, but I'm having an issue creating an array
I'm working with a web company that's approaching a point where it will likely
I have a funny feeling I'm approaching this problem wrongly. Here's what I'm trying
Might be my question sounds more naive. But I wanted to know if it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.