繁体   English   中英

当会话在drupal中到期时,如何将用户重定向到登录页面

[英]How to redirect a user to login page when session expires in drupal

有没有任何方法可以在会话到期时在drupal 6中将用户重定向到登录页面。当会话到期时,我收到一条消息"Access denied.You are not authorized to access this page." 我真的不想要显示这条消息,而是如果我可以将它们重定向到登录页面会好得多。有人可以帮帮我..

这是一个快速的伎俩:

将以下代码添加到页面模板文件的最顶层(page.tpl.php):

global $user; 
if (!$user->uid && $title == 'Access denied') { 
    header('Location: /user?destination=' . substr($_SERVER['REQUEST_URI'],1)); 
    exit; 
} 

我想你可以在主题template.php中覆盖函数: template_process_page()

在这里你可以检查全局$ user,检查是$ user-> uid ,如果它等于0,使用函数drupal_goto() ,到你想要的页面

有一个模块。 只需安装此模块即可。 它将使用登录表单替换经典的Access Denies页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM