Hosted account#
The hosted account runs on the domain in the channel's My account link, for example https://account.shop.com. You set it up like the checkout's domain, with the domain for the hosted account.
There, a logged-in customer can:
- view orders and reorder them;
- view and download invoices;
- follow shipments;
- manage the profile, addresses and password;
- manage organisations and the colleagues who share them;
- request returns, when returns are turned on for the channel.
Link to the account from your storefront, for example to https://account.shop.com/account/orders. A customer who isn't logged in there is sent to its sign-in page.
The hosted checkout only offers logging in when the channel has a My account link.
Sharing the login#
The hosted checkout and account keep the user token in a cookie named af-sid. When your storefront stores the token from logInCustomer in that same cookie, the customer is logged in on the checkout and the account too, and the other way round.
| Attribute | Value |
|---|---|
| Name | af-sid |
| Value | The user token itself, as returned by logInCustomer, registerCustomer, verifyCustomer or logInAsOrganisation. |
| Domain | Your shop's domain with a leading dot, for example .shop.com, so every subdomain can read it. |
| Path | / |
| Secure | Yes |
| HttpOnly | No: the hosted pages read it in the browser. |
| Expires | One day, or expires_at of the token. |
This only works when the storefront, the checkout and the account are on the same domain, for example www.shop.com, checkout.shop.com and account.shop.com.
The hosted pages ignore and remove an af-sid that has expired. The checkout then asks the customer to log in again.
After logInAsOrganisation or logOutAsOrganisation, write the new token to af-sid as well.
Logging out#
There is no logout call: the user token stays valid until it expires. To log the customer out, delete af-sid on the same domain and path, and drop the token from your storefront.
When the customer logs out in the hosted account, it deletes af-sid and shows its sign-in page; it doesn't send the customer back to the storefront. Read af-sid when a page of your storefront loads, so the storefront notices the logout too.