How to get User Session

I want to get User Session information for attendance record by face recognition purposes, how would I get it?

What do you mean by “User Session information”?

Authentication Information: Data that confirms the user’s identity, such as login credentials.

The framework manage that for you.

Sorry I still did not understand… should i use transaction?

The login credentials are never stored, they are just checked by the framework before executing any RPC.

But if you want to known in your code the user, you can use the Transaction.user attribute.

Is this how you used it?

from trytond.pool import Pool
from trytond.transaction import Transaction

def get_user_info():
    # Get the current user's ID
    user_id = Transaction().user
    
    # Access the 'res.user' model
    User = Pool().get('res.user')
    
    # Fetch the user record based on the ID
    user_record = User(user_id)
    
    # Return user details
    return {
        'id': user_record.id,
        'name': user_record.name,
        'email': user_record.email,
        # Add other fields as needed
    }

# Example usage
user_info = get_user_info()
print(user_info)