I am writing a program to display training records for a user. I would like to check session variables or cookies to get their user id and then perform the lookup.
I listed the session variables on a logged in account and it showed 0.
The value of the cookie matches the field value in the customer record called: CustomerGuid
So I am assuming the proper method of looking up the record of a logged in user would be to get the value of the cookie, if not blank then do a lookup in the customer table using the cookie value.
Since I am new at this I just wanted to confirm this is the correct method.
The preferred way would be to use the work context. If you're writing a plugin, or modifying a controller (that didn't already have it), you would inject it in the class constructor