3
votes

I am very experienced with PHP etc but a Drupal newbie. I would like to know if there is a way I could put in some additional PHP code once a user has logged in to a Drupal site. The reason I need to do this - to update fields in a different database (not the MySQL Drupal DB). I would need to have access to the Drupal site login username and the session cookie generated by drupal. I would be most grateful for any help.

2

2 Answers

8
votes

Create a module and implement the hook_user hook to check for a login action.

If your module name is mymodule, then create a function called

mymodule_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'login') {
    // Perform your task.
  }
}

More information on the user hook is here: hook_user

0
votes

You can access the global $user object in the hook_user to get the name and session info.