Viewing 1 replies (of 1 total)
  • Thread Starter NYCdev

    (@nycdev)

    figured it out.

    /*
    * Update last activity for a user
    */
    add_action( 'init', 'update_session_activity' );
    function update_session_activity() {
        if ( is_user_logged_in() ) {
            $manager = WP_Session_Tokens::get_instance( get_current_user_id() );
            $token = wp_get_session_token();
            $current_user_session = $manager->get( $token );
    
            // update last activity to current server time
            $current_user_session['last_activity'] = time();
    
            // update current session with new activity time
            $manager->update($token, $current_user_session);
        }
    }
Viewing 1 replies (of 1 total)

The topic ‘Updating current session data?’ is closed to new replies.