Answer the question
In order to leave comments, you need to log in
Where is it more correct to write down what questions the user has already answered (quiz site)?
I decided to make a space-themed quiz site for a college contest.
The whole quiz will be on one (main) page of the site. Questions are updated via AJAX. Each next question is chosen randomly from the table of questions.
(There are two tables in the database - Questions(question_id,question_text) and Answers(answer_id, question_id,answer_text,is_corrext)) The
next question is where to store the question_id selected by the user for his answer_id, and, probably, the number of the last question? This is to count the results at the end, and not give the user the same question twice.
Should this data be stored in cookies, or in the Session? Are there any pitfalls in this case, the risks that the data will be confused / lost?
You can take the quiz without authorization.
Although the competition and the project is not serious, I myself want to do everything right right away.
Answer the question
In order to leave comments, you need to log in
cookies - storage accessible to the user for editing. It is a bad idea to store any results in it, I will write to myself that I answered all the questions correctly and - profit, I am Elon Musk.
Ideally, create a table in the database, where just a randomly generated number / hash is entered, the same hash is stored in the user's cookie. When entering, the cookie is checked - if it has already been entered - pull out all the results, if something has been decided - write it to the database by the key from the cookie.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question