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.
So let's go through the following steps, in order to create the UserService
class:
1. Create a new PHP file inside the
Service
directory namedUserService.php
, and type in the following class:<?php namespace My\Service; use My\Dao\UserDao; use My\Service\ValidatorService; class UserService { public...