How to redirect the user using hook_init? If the user requests www.mysite.com/user/login he should be redirected to www.mysite.com/mylogin. I know this is possible with hook_init or hook_boot, can some one explain how this can be achieved.

Thanks
/**
 * Implements hook_init().
 */
function mymodule_init() {
  global $base_url;
  if (user_is_anonymous() &amp;&amp; arg(0) == 'user') {
    drupal_goto($base_url . 'mylogin');
  }
}