+ Start a Discussion
JP12345JP12345 

how to cache user information in current salesforce session?

How to cache logged-in user information(e.g. user profile,userID,country) to current session in salesforce?
SFFSFF

I think you're looking for this:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

 

userInfo doesn't have ALL of the attributes of the user record, and if you want them you'll have to query the database. If desired, you could "cache" this information in a static variable, but be aware that data in a static variable is NOT shared between execution contexts, so this is not a true cache. You could, I suppose, do something clever with a cookie or a custom setting, but generally I just re-query the database as needed (while keeping my code a bulk-friendly as possible, of course).

 

Hope this helps,