Created
March 26, 2019 12:25
-
-
Save syammohanmp/30526e829df20b8a9e42541e964b21ea to your computer and use it in GitHub Desktop.
Auto login as admin user in Drupal 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uid = isset($_GET['uid'])?$_GET['uid']:1; | |
$user_name = isset($_GET['user'])?$_GET['user']:NULL; | |
define('DRUPAL_ROOT', getcwd()); | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
global $user; | |
$user = user_load_by_name($user_name); | |
if(FALSE === $user) { | |
$user = user_load($uid); | |
} | |
drupal_session_regenerate(); | |
drupal_goto('user'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment