Skip to content

Instantly share code, notes, and snippets.

@syammohanmp
Created March 26, 2019 12:25
Show Gist options
  • Save syammohanmp/30526e829df20b8a9e42541e964b21ea to your computer and use it in GitHub Desktop.
Save syammohanmp/30526e829df20b8a9e42541e964b21ea to your computer and use it in GitHub Desktop.
Auto login as admin user in Drupal 7
<?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