Session timeout event in magento

2019-07-19 16:04发布

问题:

I wanted to do some custom functionality upon user logout, so I hooked to the customer logout event, and added an observer to it.

Here's the configuration in config.xml

<customer_logout>
  <observers>
    <cwmyaccount>
      <type>singleton</type>
      <class>KrtMalta_Myaccount_Model_Observer</class>
      <method>setRegularCustomer</method>
    </cwmyaccount>
  </observers>
</customer_logout>

However I'd like the execute my custom functionality even on session-timeout. I've looked up google and Magento files with pretty much no success. Is it possible to hook to session-timeout somehow?

回答1:

Sessions are cleaned up automatically by PHP when a session is started and there is currently no way to hook into this process unless you write your own custom session handler.

If you write your own handler, then PHP will call your gc method giving you control over the old session data that gets destroyed. Keep in mind that this happens at the start of the request (when session_start() is called) so you would want whatever processing you do to happen very quickly as not to delay the request being processed.



标签: php magento