Contact me!
Eric Håård
+46 (0) 73 375 86 06

StormContext

The StormContext is a cookie based container of user and setup data for Storm accessible through out the application. It provides means to log in and out a user. It can be encrypted in Web.config so no one can tamper with the cookie.

Persisted cookie for 30 days

Property Type Description
AccountId int? Logged in Account Id. Null when not logged in. AccountId is used to tag who updated data through Storm API. Pass this when required in updates so Storm API knows who changed data.
LoginName string Logged in Account Login Name. Null when not logged in.
RememberMe bool? Current setting for if account will be remembered between settings or not. Set this in the login page.
CustomerId int? Current Customer Id. Used to set basket when logged in and to show the right information in my pages.
CompanyId int? Current Company Id. Used to set basket when logged in and to show the right information in my pages. A customer can be connected to more than one company.
DivisionId int? Current Store or Division Id. Used to set basket when logged in if a store is selected and to show the right store on hand information.
BasketId int? Current Basket Id. Use Api call CreateBasket when basket id is null to get a new basket Id.
CurrencyId int Current Currency Id. Pass this to all Storm API calls that show prices to get the returned prices in the right currency. Change this when changing currecncy.
CultureCode string Current Culture Code. Pass this to all Storm API calls that show translated text to show the right language. Change this when changing langugage.
SalesAreaId int Current Sales Area Id. Pass this to all Storm API calls that show prices to get the right VAT. Change this when changing sales area.
ShowPricesIncVat bool? Current VAT setting. Not selected when null. Use this to know if you should add VAT when showing prices on your site. Not passed to Storm API.
IsPrivate bool? Current setting for if visitor is private or company. Not selected when null. Use this to know if you should show company site or private site. Not passed to Storm API.
ReferId int? Deprecated setting that used to track what registered referrer this user last came from.

Session cookie

Property Type Description
PriceListIds List A list of activated price lists other than public price lists and price lists activated by customer, company or division. Pass PriceListIdSeed that is a comma separated string that represents this list to all Storm API calls that show prices to add available price lists.
ConfirmedBasketId int? Set in checkout process when payment is confirmed to be able to show basket on confirmation page. When payment is confirmed then StormContext.BasketId is cleared so no more changes will be made on this basket. The basket Id is copied to ConfirmedBasketId to be able to show confirmation page and set up basket tracking.
ReferUrl string Keeps track of what referrer url that inititated this session.
IsInitialRequest bool True for the first request of the session. All other request this is false.

Methods

Method Returns Description
LoginUser(loginName, rememberMe) void Logs in a user to StormContext. Sets LoginName, AccountId, first connected CompanyId, CustomerId and RemeberMe flag. Basket is updated with customer and company as long as the basket does not belong to another customer. Then that basket is closed and a new basket will be created.
LogoutUser() void LoginName, AccountId, CompanyId and CustomerId is set to null. Basket is updated to an anonymous basket.
SessionItems NameValueCollection A NameValueCollection that is stored in the session cookie. Don’t put large items here since it is transfered in every request.
PersitedItems NameValueCollection A NameValueCollection that is stored in the persisted cookie for 30 days. Don’t put large items here since it is transfered in every request.

Configuration

The following must be present in the configuration file under configuration:

 <configSections>
   <sectionGroup name="stormSettings">
      



<section name="storm" type="Enferno.Web.StormUtils.StormConfigurationSection, Enferno.Web.StormUtils" allowLocation="true" allowDefinition="Everywhere" />
    </sectionGroup>
  </configSections>

And the section should look like:

  <stormSettings>
    <storm encryptCookie="true" assortmentIdSeed="1" productStatusIdSeed="1,2,3,4" showPricesIncVat="true" imageUrl="http://services.enferno.se/image/" />
  </stormSettings>

Note that there are more settings that can be defined.

We do have a StormModule : IHttpModule located in Enferno.Web.StormUtils that hooks into the application’s Begin-/EndRequest in order to handle Load and Save of cookie data.

The StormModule is registered in the configuration file as:

<system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
            <add name="StormModule" type="Enferno.Web.StormUtils.StormModule, Enferno.Web.StormUtils" preCondition="" />
        </modules>
</system.webServer>