How to restrict access to page by URL depending on which page you came from I have page which implements by hook_menu and i want to permit access for this page if user come from certain form but not from just url string. How can i solve it? Thanks.
depending on which page you came from


per se is impossible, because people can easily forge their referer header. What you need to do in your specific, form related situation is to:


In form submit handler, set session variable, like $_SESSION['acces_valid_to'] = time() + 3600 - this will store time one hour into future for specific user.
In access hook, for example hook_node_access if we are talking about nodes, test if this variable is set, and if it is still valid. If not, send 403 Forbidden.
If you want, you can unset it after any page view, that will make sure your user will view his page only once.


If you will have specific problems with any of these steps, ask next, more specific question.