I am creating an admin panel for my website. I have heard that it is possible to protect it in the following way:

Admins (who should be able to access the admin panel) get a certain cookie.
This cookie then allows them to get into the admin panel when they go to the panel directory.

When anyone else goes to the panel directory, just gets taken back to the homepage, and doesn't see anything on the panel

How would I do this?