Sunil Bhawsar
Sunil Bhawsar

Reputation: 199

How to get Last Logout time of user in Openfire Server using php code

How to get Last Logout time of user in Openfire Server using php code. How i will achieve this I am new on Openfire.

I googled a lot. But haven't found any article about my questions. Is there any way to get "last seen" or "last activity" date from Openfire server?

Please help me. Thanks in advance.

Upvotes: 1

Views: 751

Answers (2)

Shoaib Ahmad Gondal
Shoaib Ahmad Gondal

Reputation: 646

If you don't want to communicate on XMPP and you have access to Openfire's database, then you can also query the database for last seen time.

Table: ofPresence

You can query for "offlineDate" against "username" and you will get time in milliseconds: 001448886257729

Whenever a user comes online (sends his presence to Openfire Server), his entry is removed from this table. So for an online user, you won't get any record.

Hope it will help.

Upvotes: 1

beaver
beaver

Reputation: 17647

You can use XMPPHP library to manage XMPP connection to Openfire in PHP; there are several fork from the project originally hosted on Google Code, for example:

Example of usage are easy to find, however here are some of them:

In your case, after having created your connection to XMPP server (Openfire) with:

$conn = new XMPPHP_XMPP(...);
$conn->connect();

you can send a generic XML message with $conn->send($xml); or a specific IQ message with $conn->sendIq(...);.

Follow xep-0012 doc to create appropriate XML to obtain Last Activity info for a user.

Upvotes: 2

Related Questions