Database Save/Read

Discussion in 'Customization & add-ons' started by engineerwsu, Nov 6, 2020.

  1. engineerwsu

    engineerwsu Member

    Joined:
    Sep 18, 2014
    Messages:
    31
    I have created a user field. I insert a date into the database using the following code which is inserted into the site.php file.

    Code:
     Am_Di::getInstance()->hook->add([Am_Event::USER_BEFORE_UPDATE, Am_Event::USER_BEFORE_INSERT], function(Am_Event $e) {
       $e->getUser()->date_modified = sqlTime('now');
    }); 
    I then lookup this entry on a page using Am_Lite as below:

    Code:
    Am_Lite::getInstance()->getUser(['date_modified']);
    This seems to work fine. But, I notice if I change the database entry directly in the database (or even delete it entirely) and then lookup with Am_Lite again, the entry does not change. It's almost as if it's been cached somewhere else. Why would this be?
  2. engineerwsu

    engineerwsu Member

    Joined:
    Sep 18, 2014
    Messages:
    31
    A little further information about this. I found that when the user logs out and logs back in, the database query correctly pulls up the field from the database. It seems the user profile data is cached somehow and gets purged at logout.

    Question, how do I manually request the user profile data to refresh? It is very possible I will need to modify the user data either manually or outside aMember.

    Thank you.
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Am_Lite retrieve info about logged in user from session. It can not reload session data.

    User need to open any aMember page in order to reload data in session.

    Best Regards.

Share This Page