You can lock a directory with a password by using the cPanel Password Protected Directories Option.
Log into your cPanel account.
In the Files section, click on Directory Privacy Icon.
Click the icon to open a folder.
Click on the name of the directory you want to protect by password.
Under Security Settings, check the box next to the Password protect this directory and enter a name for the protected directory like Password Protected Area. Then click the Save button.
Now click on the Go back button.
Now, should you try to open your password-protected directory in your browser through the URL www.example.com/myfolder, which is already password protected, your browser will prompt you to enter username and password.