Alternative to $user->lastVisit() with ezpSessionHandlerPHP

Author Message

Benjamin Lorteau

Monday 14 March 2011 9:11:07 am

Hi everybody,

I recently upgraded to 4.4, but I encountered some problems with login and remembering login tied with session management.

Here I have a new regression to submit to your consideration. I un a site/forum that rely heavily on the content/newcontent feature, which is based on the user's last visit timestamp. Unfortunately, with the new session handler, this timestamp is updated every time the user load a page, cancelling the new content system.

My question is : how can I replace $user->lastVisit() in my scripts to get the old behavior (last time the user logged in) ?

Thanks in advance !

eZ Publish personal project : http://www.aeriesguard.com [fr]

André R.

Tuesday 15 March 2011 5:31:48 am

(re edit) Added your issue to the issue tracker here:

http://issues.ez.no/IssueView.php?Id=18144&activeItem=1

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

André R.

Tuesday 15 March 2011 5:59:35 am

Might have a patch for this to make sure eZUser does not update last visit ts:

diff --git a/lib/ezsession/classes/ezpsessionhandlerphp.php b/lib/ezsession/classes/ezpsessionhandlerphp.php
index 72c574e340a7c8158e19333bcf787e1edd7bc35a..cf199c8ac3996a640c6097874a311e8284f23121 100644
--- a/lib/ezsession/classes/ezpsessionhandlerphp.php
+++ b/lib/ezsession/classes/ezpsessionhandlerphp.php
@@ -28,6 +28,8 @@ class ezpSessionHandlerPHP extends ezpSessionHandler
         {
             ini_set("session.gc_maxlifetime", $ini->variable('Session', 'SessionTimeout') );
         }
+        // make sure eZUser does not update lastVisit on every request and only on login
+        $GLOBALS['eZSessionIdleTime'] = 0;
         return true;
     }
 

Edit: This issue has been fixed and commit is available here (for stable-4.4): https://github.com/ezsystems/ezpublish/commit/fdf56b18b35df841f232f9e1f4f8c43506fd0621

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Benjamin Lorteau

Tuesday 15 March 2011 6:54:52 am

This fix worked for me, and I'm using ezUser::updateLastVisit() to manually update the users' last visit timestamp.

Thanks a lot Andre !

(Topic marked as solved)

eZ Publish personal project : http://www.aeriesguard.com [fr]

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.