The tool you want to use is Zend_Auth , which is pretty easy to use when you hang it.
Checking a userโs login can be as simple as: -
$auth = Zend_Auth::getInstance(); if($auth->hasIdentity()) $loggedIn = true;
See Rob Allen for a great tutorial on getting started with Zend Auth .
The method I use is to set up a user class that searches for authorization and access control and enters it into my application as an Assistant in action , so in any of my controllers I can simply do: -
$this->user->checkSomething();
Part of the authorization should affect all parts of your site that you do not want to publish, and each affected controller must verify that the user is logged in. For access control, which is performed for each role / per resource, depending on how fine-grained you should be. See ACL and AUTH in the manual.
source share