Opening user session programmatically using headers information I'm developing a website with an external user authentication provider. The whole login process is external, that I don't need to worry about. Once a user is logged in, the external provider adds extra data in the request headers (i.e. customer id), that I can use to map an external customer id with a user from the Drupal users table.

Which hook suits the best to open a session and login the user programmatically on each page request? (hook_boot() ?)
As the hook_init() doesn't works for the cached pages so the alternate option that seems to me is the hook_boot() (This hook is run at the beginning of the page request. It is typically used to set up global parameters that are needed later in the request), 

However the discussion here on using the session during hook_boot make me feel that hook_boot() is invoked too early to use the session, as Drupal has not yet initialised the session.


  There is a trick to avoid the page is cached: Call drupal_page_is_cacheable(FALSE) in hook_init().


Check more here: using drupal sessions during hook_boot