Answer the question
In order to leave comments, you need to log in
Saving data of an unauthenticated user?
In general, there is something similar to an online store, in the form of a website adapted for mobile. devices.
The user can "rummage" through the catalog, add products to the basket, after which he presses the "make an order" button, enters his house. address and order delivered. Actually, the very saving of all data in the database occurs at the stage of pressing the "make an order" button.
It would seem that everything is fine, the order was displayed at the administrator. However, the user himself also has a "My Orders" tab, where he can see the status of his order (in processing, being prepared, delivered, delivered). Now the user cannot see anything, because the order in the database is not connected to the user in any way.
Question: How to make it mono with a minimum of crutches and shit code?
Answer the question
In order to leave comments, you need to log in
If you work only with mobile devices, you can safely use localStorage. When you save an order, generate some kind of token that you return in response to the save request along with the order ID. Save the token and identifier along with the order data in localStorage. In the future, if necessary, display order data from localStorage. Identification (in this case, the correctness of the browser, not the client) is made by checking that the token matches the order identifier. It is more correct to do this by requesting the backend. For the user, everything will be absolutely transparent.
Store order information in a Cookie. You must understand that this is like a computer's RAM - the data is stored on the user's side, but the storage is temporary, and if he logs in from another device or deletes the cookie, then his connection with the order will also be lost.
The simplest solution is to only ask for Email. Send order information and a link to track the status to it. You may not even require a password to view the status. Generate unique links for different orders. This is the easiest option in my opinion.
For example, create a new user, save data and send him a login and password from the site by email.
The order is written to base?
1. After saving to the database, we write a cookie to the user.
2. The unique identifier will be the address of the order, for example with spaces removed. (here you can make the address filling form more strict in order to more accurately identify the user)
You give him data, what kind of e-mail do you still send?
With order refinements, at least not to do so would be foolish.
Dk here, you still have some kind of order number.
On the site you make a separate form, it has one field, something like "Check order status". A person enters the order number, for which you can give him, for example, the status of the order.
It would be more correct to use localStorage or something based on cookies. In this case, the user will have access to his orders until he clears the history)
Do not invent nonsense, you need to generate passwords by email and send them to the mail. You will open the data of all your customers with these cookies...
Show him the client's temporary code, example: 2424-3335-4353
(where the first 8 are the logon, the last 4 digits are the PIN)
Write that the code is valid - the month.
and
the field for entering the mail below...
Let him choose!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question