简体   繁体   中英

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." .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):

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 .

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

There is a module for that. Just install this module. It will replace the classic Access Denies page with the login form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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