Lookup user record based on login

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
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.

Where do I look for this information?
11 years ago
I think I found it.

There is a cookie called:  Nop.customer

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.
11 years ago
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

IWorkContext _workContext;
...
_workContext.CurrentCustomer
11 years ago
I am writing my own code for a seperate function and simply want to use the nopcommerce user record rather than creating a seperate user file.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.