[英]How to redirect a user to login page when session expires in drupal
Is there any means by which you can redirect a user to the login page once the session expires in drupal 6
.Now when the session expires I get a message "Access denied.You are not authorized to access this page."
有没有任何方法可以在会话到期时在drupal 6
中将用户重定向到登录页面。当会话到期时,我收到一条消息"Access denied.You are not authorized to access this page."
.I really don't want this message to be shown ,rather it would be much better if i could redirect them to the login page.Could someone please help me.. 我真的不想要显示这条消息,而是如果我可以将它们重定向到登录页面会好得多。有人可以帮帮我..
Here is a quick trick: 这是一个快速的伎俩:
Add following code to the very top of your page template file (page.tpl.php): 将以下代码添加到页面模板文件的最顶层(page.tpl.php):
global $user;
if (!$user->uid && $title == 'Access denied') {
header('Location: /user?destination=' . substr($_SERVER['REQUEST_URI'],1));
exit;
}
I think you can overwrite function: template_process_page() in your theme template.php . 我想你可以在主题template.php中覆盖函数: template_process_page() 。
here you can check global $user,to check is $user->uid ,if it is equal 0,use function drupal_goto() ,to the page you want 在这里你可以检查全局$ user,检查是$ user-> uid ,如果它等于0,使用函数drupal_goto() ,到你想要的页面
There is a module for that. 有一个模块。 Just install this module. 只需安装此模块即可。 It will replace the classic Access Denies page with the login form. 它将使用登录表单替换经典的Access Denies页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.