I am a little confused on storing sessions with regards to having multiple users logged in at the same time…Does the session key have to be unique or just the value? Like is this ok, if all the $userIds are unique?
//if the user logs in:
$_SESSION['loggedIn'] = $userId;
In testing this it seems like if you have two logged in with separate $userIds at the same time and are trying to enter data to a db, it causes errors. Should the key be a random #? Not worried about security at this point.
$_SESSIONis stored on the server side and is not a good way to track a user as a session can be terminated after a short period of inactivity. You’d be better off using cookies, if possible.But to address your specific question, your code should work as the session will almost always be unique.