Re: [development] No last access?
No luck with that. Time code shown in database = 1171293946 timecode called by using the following global $user; $account = user_load(array((is_numeric($user->uid) ? 'uid' : 'name') => $user->uid, 'status' => 1)); print $account-access; 1171294179 You see the trick here is that to see the printed time you have to login. Since there is no last login stored the $object->access pulls thle only thing available. What I have done in my module is store the time in another field so I have lastaccess and newaccess. Newacess is being constanly updated by the user object. But lastaccess only accepts a value from newaccess. When newaccess is updated the old value goes to lastaccess which is what I want to be able to use. I could not find anything in the present core that does this. Carl Mc Dade ____________________________ Web Developer ----- Original Message ---- From: John VanDyk <jvandyk@iastate.edu> To: development@drupal.org Sent: Monday, February 12, 2007 3:55:48 PM Subject: Re: [development] No last access? http://drupal.org/node/91786 "user_load() clarification"
I can imagine the the global user might not have the info in it... but if you do user_load(array('uid' => $user->uid)); // <-- $user is global user, you might get a hold of it. Just shooting from the hip.
Moshe Weitzman wrote:
Carl Mc Dade wrote:
Well, I spent sunday evening being sick and looking over last access functionality historically as per Bérs advice. I looked back to version 4.4 to 4.7.4. a found surprisingly that Drupal has never really had a last access functionality. It has had calculation code to gather such information but nothing definative. Strangely enough there has not been too much call for this information so no one has noticed.
This is all nonsense. The user admin page shows you last access for each user. And that number is accurate, so we must be collecting that info somewhere. Furthermore, access is easily available for all modules in the standard $user object.
Fire up your debugger and you will see the writing of this infomation in sess_write().
-- * * * * * Lullabot's First Ever Advanced Workshops Are Here! Drupal API & Module Building - Advanced Drupal Themeing April 9th-13th - Providence, RI Early Bird Discounts Available Now http://www.lullabot.com/training * * * * *
____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html
Is there no longer a last access functionality? using the global user and calling $user->access gives the value after the database has been updated. Not the value in the database at the time of login. Ex. the value in the database table is 0000002. You will not get this value but the value 0000003 which is the time of the latest access.
The above was your original question.....
No luck with that. Time code shown in database = 1171293946 timecode called by using the following <snip> print $account-access; 1171294179
Erm, am I missing something here or should you not be doing:- print $account->login; "login" holds the timestamp of the last login, "access" holds the timestamp of the last browser hit for the user. This is from user.module:- // Update the user table timestamp noting user has logged in. db_query("UPDATE {users} SET login = %d WHERE uid = %d", time(), $user->uid); and this is from session.inc:- db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid); regards, --Andy
participants (2)
-
AjK -
Carl Mc Dade