How can you get the userid="" in the URL when the user is logged in. I have mysql database with table users. I wan to know the code which basically knows what is the id of the user that has logged in. And using sessions but not sure about the code.

And after userid set in session you can retrieve it on any page using $_SESSION["userid"]

Happy Coding

网友答案:

Why you need userId in url, its creates security problem, if you pass userId and user changed the id in url then in backend you will end up doing the operation on wrong userId, always take the user details from session.

See this answer for explanation on how you can store user info to session

网友答案:

You should store the userid in the session (for example ($_SESSION["userid"]))