I created a simple menu link and need it to be visible for both authorized and anonymous users. But when a unauthorized/anonymous user click it should check authorization and if not it should redirect to login page. How can i do this. Thanks
If you made the link via the drupal admininstration area and Menu or Menu Items ... or you've made the menu item using hook_menu() ... then you just need to define an 'access callback' for the menu item. See hook_menu() documentation for how to do this -- if the user is anonomous then you will return False from this custom callback function.
If you dont have a custom hook_menu() in a function but made the menu item via the Adminstration UI, then implement hook_menu_alter() to change the menu item stored in the database and add the "access argument".
If you're just echoing an html link in some page without having the link come from the database .... good luck.
Yes you can do this just go to admin/config/system/site-information (if using drupal 7) there you will see a Error Pages title at the bottom of the form there you can see an option as Default 403 (access denied) page. You can mention your login page path within that text box user/login. I hope this works for you