It's possible execute a trigger php code when user logoff ?

Hi,

it is possible in same way execute some php code when user logoff (auto mode) ?

Because this is usefull to me the php code should know who is the user that just logoff ...

Thank
 
hi
We don't have anything for that, you would need to write a small Joomla user plugin to achieve what you are after.

Take a look at plugins/user/joomla. I'd copy that - rename its folder and files to something appropriate and then in joomla.php - there's a onUserLogout() method which you could alter to match your needs.
 
hi
We don't have anything for that, you would need to write a small Joomla user plugin to achieve what you are after.

Take a look at plugins/user/joomla. I'd copy that - rename its folder and files to something appropriate and then in joomla.php - there's a onUserLogout() method which you could alter to match your needs.

Thank you rob,

this code is executed if user logout by closing the browser or for timeout ?
 
That would only get triggered when the user actually logs out, using the Log Out button in J!.

I'm pretty sure there isn't any kind hook for a session timeout. or closing the browser. Closing the browser is totally out of J!'s control or knowledge. You could technically add some JavaScript in your pages which catches the Javascript 'onBeforeUnload' event, and make an AJAX call to the server. But that's a Bad Idea, for several reasons.

Sessions are timed out automatically by J! about ever other page load (it's random, designed to happen about half the time), i.e. when anyone using the site loads a page. At the point during the J! framework load where J! checks to see if there is an existing session for the user loading the page, it also simply deletes all timed out sessions from the #__session table, without any kind of hook or notification happening.

The problem is, there is no plugin hook in J! that runs before J! clears dead sessions from the #__session table. So no way to know when J! does this, or that it has happened.

The only way I can think of doing this would be a little bit long winded, but should work.

You'd need a MySQL trigger, set to run ON DELETE on the #__session table. In that trigger, write the row data from the __SESSION row into your own "temporary" table, called something like sessions_deleted.

Then create a system plugin (look at any of the existing system plugins to base yours on), with an onAfterInitialize() method, which reads your sessions_deleted table, does whatever processing it is that you are doing in your onAfterLogout() method in the user plugin Rob described, and delete all the rows from your sessions_deleted table.

So ... the idea is, the MySQL trigger captures the rows that J! deletes during the framework load, your onAfterInitialize plugin grabs those, does what you need to do on a logout / session timeout, and zaps the rows you processed.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top