tags:

views:

239

answers:

1

Hello All,

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.

+5  A: 

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

alxp
Thank you very much! I had managed to figure this out in the mean time. However, I have a follow on question - is there a way I can do any/all of the following from mymodule_usera. Determine the name of the user logging in/outb. Determine the session ID for the Drupal sessionc. Send back a custom cookieI'd be most grateful for any help.

related questions