This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Alternative to $user->lastVisit()...
expandshrink

Alternative to $user->lastVisit() with ezpSessionHandlerPHP

Alternative to $user->lastVisit() with ezpSessionHandlerPHP

Monday 14 March 2011 5:11:07 pm - 3 replies

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 !

Tuesday 15 March 2011 1:31:48 pm

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

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

Modified on Tuesday 15 March 2011 1:49:43 pm by André R

Tuesday 15 March 2011 1:59:35 pm

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

Modified on Tuesday 15 March 2011 2:41:36 pm by André R

Tuesday 15 March 2011 2:54:52 pm

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)

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from