Isso não é possível. Citando aqui :
There is only one login hook, which means that it's not suitable for shrink wrap developers because you can't be guaranteed that the user hasn't already installed some other software that's using it. In general, you should consider the login hook to be reserved for use by site administrators.
O artigo vinculado menciona várias alternativas. Um agente de inicialização pode funcionar para login, dependendo de seus requisitos específicos.
Não há alternativa para os ganchos de logout. Citando o mesmo artigo:
Specifically, while the authorization plug-in technique described in this technote is a good alternative for the login hook, there is currently no equivalent replacement for the logout hook.
Veja também esta pergunta sem resposta .