We will use
My\Service as the namespace for this class, and keep any constants in the class. The
UserService class attributes will contain the user information, such as the user e-mail, user ID, username, or phone, and the constructor checks for logged in user and class variables loaded with the user details from the session. Also, the class will make use of PHP cookies to store the user's login data. The class will act as the login session manager. So initially, the class will check for the login data in sessions or in cookies that the user is logged into.
It is recommended that you are familiar with PHP sessions and cookies for this tutorial.
So let's go through the following steps, in order ...