In Zend Framework whats a better method to restrict user from accessing post login pages
if the user is not logged in.Without Zend I would have write a code to check if the
userid is set in session or not and put that code in common file(being used on all post
login pages).
In Zend Framework I can check that using hasIdentity method of zend_auth but I don’t
want to check that inside all actions.The another method I am thinking is to create a
plugin and hook it to routeshutdown event,then after fetching controller and action
name from request object I can decide whether to redirect user or not.
Please suggest some good method to implement it in zend framework
You would normally write a Controller Plugin and add it to the front controller. This way you can intercept the dispatch and route process where you want and issue a redirect to an appropriate page.
In the Bootstrap class:
BTW: This is Zend Framework 1 – might work the same in 2, but I believe you might change things a bit there if you already use it.