using hook_user() to capture user actions
hope you are trying for drupal 7, there are hook for login and logout, hook_user_login and hook_user_logout respectively. the user id available for logout hook so you can populate the data you want about user.