I want to know when a user is logged in and logged out from an ejabberd session in a custom module, without changing the ejabberd code.
I need that because I have to execute some actions when a user logs in and clean up the actions I did when the user logs out. Also, I need to be able to logoff a user given some circumstances.
So, is there a way to extend some module to get those feature? I'm still looking for some documentation that could help me with that.
You can write your own code and build it has a plugin with the behaviour gen_mod that ejabberd gives you. A nice place to begin with is this blog/tutorial and follow to next part. This should be enough but you will find more on the same blog.
After you get a little more comfortable with building your own module I suggest you take a look at the hooks set_presence_hook and unset_presence_hook
Just notice that set_presence_hook is activated every time a presence is set, not only on log in, you just have to work that around, if you can.
Long story short you will end up with something like the following
Hope this help