Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6907607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:27:21+00:00 2026-05-27T08:27:21+00:00

I want to know when a user is logged in and logged out from

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:27:22+00:00Added an answer on May 27, 2026 at 8:27 am

    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

    -module(mod_your_mod).
    
    -behavior(gen_mod).
    -include("ejabberd.hrl").
    
    -export([start/2, stop/1, on_set/4, on_unset/4]).
    
    start(Host, _Opts) ->
       ejabberd_hooks:add(set_presence_hook, Host, ?MODULE, on_set, 50),
       ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE, on_unset, 50),
       ok.
    
    stop(Host) ->
       ejabberd_hooks:delete(set_presence_hook, Host, ?MODULE, on_set, 50),
       ejabberd_hooks:delete(unset_presence_hook, Host, ?MODULE, on_unset, 50),
       ok.
    
    on_set(User, Server, _Resource, _Packet) ->
    <presence code>    
    
    on_unset(User, Server, _Resource, _Packet) ->
    <offline code>
    

    Hope this help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know that Filename1, provided by the user is the same as
I want to add a feature to our application that let's a user know
Ok so what I want to happen is when a user is logged out
I want to display a message to the user saying, you're logged out re-login
I want to know when a user is touching the screen but not moving.
I want to know column index of header in AdvancedDataGrid when a user clicks
I'm using Google App Engine python. I want to know what browser the user
I want that everyone can send a message to a friend after the user
I know this sounds very dumb, but we have a client that sends out
I want to create a timesheet application where I need an application that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.