How to get session at PrepareProductOverviewModelsAsync

2 weeks ago
I want to get a created Session in the above function but the usual:

HttpContext.Session.GetString("key");


does not work. So how can I do it ?

Also is this the best approach to pass values here using Sessions or there is something else built-in nopcommerce.
2 weeks ago
See an example of how it's done in
\Libraries\Nop.Services\Authentication\External\ExternalAuthenticationService.cs
protected virtual IActionResult ErrorAuthentication(IEnumerable<string> errors, string returnUrl)
        {
            var session = _httpContextAccessor.HttpContext?.Session;

            if (session != null)
            {
                var existsErrors = session.Get<IList<string>>(NopAuthenticationDefaults.ExternalAuthenticationErrorsSessionKey)?.ToList() ?? new List<string>();
...
2 weeks ago
The other question still remains is this the ONLY way to pass on variables or is there something built-in in nopcommerce.
2 weeks ago
Using Generic Attributes is the typical way it's done.  For example, see

\Presentation\Nop.Web\Controllers\CheckoutController.cs
public virtual async Task<IActionResult> SelectBillingAddress(...
...
await _genericAttributeService.SaveAttributeAsync<ShippingOption>(customer, NopCustomerDefaults.SelectedShippingOptionAttribute, null, store.Id);