R
R
Red Rain2015-12-12 21:07:31
PHP
Red Rain, 2015-12-12 21:07:31

How to bind session to user id?

Hello. I am writing a simple online store for a term paper. There are several databases, including a database of users with their id, login, etc. The entire basket is stored in $_SESSION['basket']. And the login and id of the already authenticated user is stored in $_SESSION['user']. Sessions have a +1 week lifetime and are stored in the site folder.
Problem actually with division of sessions of each user. If one user logs out and another logs in on the same computer, the same basket opens. How to tell Sessions to open an old session whose name, for example, begins with the user id?
The teacher will not check the code, the main thing is that it works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2015-12-12
@CodeDes3D

If the user is authorized, then store his cart in the database. Otherwise - in session.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question