> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# WC- (WelcomeBack function)

> Greet returning visitors by name: check whether the function is active and data is available, output fields from the WelcomeBack cookie and offer the link for resetting.

When a buyer returns to the shop after a few days, they are no longer logged in, but the shop still knows who they were. The WelcomeBack function lets you make use of this: a personal greeting by name, a note about the last visit, and a way back into the customer account.

The `WC-` tags build this greeting. Five tags are enough for this, because the shop configuration does the actual work.

Reference: `WelcomeCookie` section in the shop configuration

> [!NOTE]
>
> All tags are permitted on all templates. You define which fields are available in the `WelcomeCookie` section of the shop configuration.

## Two checks before the greeting

Before you display a name, two questions need to be answered: is the function switched on at all, and is there data for this visitor.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{WC-Active}
   {WC-Data}
      <p>Guten Tag ~WC-Data_FirstName~ ~WC-Data_LastName~.</p>
   {/WC-Data}

   {!WC-Data}
      <p>Willkommen in unserem Shop.</p>
   {/!WC-Data}
{/WC-Active}
```

| Tag | Applies when |
| - | - |
| `WC-Active` | the WelcomeBack function is switched on in the shop configuration |
| `WC-Data` | data is available for this visitor |

> [!NOTE]
>
> `WC-Active` queries a pure configuration setting. The bracketing is mainly useful during setup, because it immediately shows in the template whether the function has been enabled at all.

> [!WARNING]
>
> `WC-Data` only applies when two conditions are met at the same time: there is something in the cookie, **and** the visitor has not declared via the reset link that they are someone else. The previous documentation only mentions the first condition. After a click on the link, the range therefore stays silent, even though the cookie is technically still there.

> [!NOTE]
>
> If the function is switched off, all tags except `WC-Active` output nothing, and their bracketings do not apply. So you can also write the greeting block without `{WC-Active}`. The nesting does, however, make the intent in the template more readable.

## The fields from the cookie

`WC-Data_` followed by the technical field name outputs the respective field.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{WC-Data}
   <p>
      Guten Tag
      {WC-Data_FirstName}~WC-Data_FirstName~ {/WC-Data_FirstName}~WC-Data_LastName~.
      {WC-Data_LastLogin}Ihr letzter Besuch war am ~WC-Data_LastLogin~.{/WC-Data_LastLogin}
   </p>
{/WC-Data}
```

| Tag | Returns |
| - | - |
| `WC-Data_<technical field name>` | the field from the stored data |
| `WC-Data_LastLogin` | the date of the last login |

> [!NOTE]
>
> You determine which fields exist in the `WelcomeCookie` section of the shop configuration via the `Fields` subsections and their `AddressField` parameter. There you enter the technical field names separated by commas, and exactly these names are what you then append to `WC-Data_`.

> [!WARNING]
>
> Only fields of the **billing address** are available. The shop system matches the names against the field definition of the billing address, other fields cannot be included. The previous documentation speaks generally of fields from the shop configuration.

> [!WARNING]
>
> A field name that is not configured is **not** reported as an invalid tag. The tag simply outputs nothing, and a bracketing around it hides its content. If a spot remains unexpectedly empty, first check the field name against the shop configuration.

> [!WARNING]
>
> `WC-Data_LastLogin` also works as bracketing, namely when a date is available. The previous documentation lists it only as a single tag. The bracketing is worthwhile, because for a visitor without a stored login date there would otherwise be a sentence with an empty date on the page.

> [!NOTE]
>
> All field tags work as bracketing when the field is filled. Use this for fields that not every customer fills in, for example a salutation or a title.

> [!WARNING]
>
> The field values are output **without HTML encoding**. This is data that the customer entered themselves during registration. So do not write it unchecked into an attribute or a script, only into visible text.

## The way back to anonymous

Not every visitor is the same person. On a shared computer, the shop would otherwise greet the wrong person by name.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{WC-Data}
   <p>
      Sie sind nicht ~WC-Data_FirstName~ ~WC-Data_LastName~?
      <a href="~WC-DeleteLink~">Begrüßung zurücksetzen</a>
   </p>
{/WC-Data}
```

> [!NOTE]
>
> `WC-DeleteLink` is exclusively a single tag. The link deletes the WelcomeBack cookie, and the greeting does not appear until the next login.

> [!WARNING]
>
> Always offer this link when you greet someone by name. Without it, a visitor on a shared computer has no way of getting rid of someone else's greeting.

> [!NOTE]
>
> The generated link uses HTTP, not HTTPS. This is not critical, because nothing is transmitted except the command to delete the cookie. If your shop runs exclusively via HTTPS, check the link once in the finished template anyway.

## What is in the cookie

> [!NOTE]
>
> The cookie itself contains no names. It only contains an identifier that the shop system uses to look up the data in its own database. The visitor's browser therefore does not carry any address data around.

> [!NOTE]
>
> The cookie is called `ws_<Shopkennung>_<Sprache>_welcome_cookie`. How long it is valid is also specified in the `WelcomeCookie` section of the shop configuration.

> [!WARNING]
>
> Keep the greeting block lean and only access the fields you actually display. Every field access draws on the database, and a block with a dozen fields appears on every page of the shop.

## A complete example

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{WC-Active}
   {WC-Data}
      <div class="welcomeback">
         <p>
            Guten Tag
            {WC-Data_FirstName}~WC-Data_FirstName~ {/WC-Data_FirstName}~WC-Data_LastName~.
            {WC-Data_LastLogin}Ihr letzter Besuch war am ~WC-Data_LastLogin~.{/WC-Data_LastLogin}
         </p>
         <p>
            <a href="~WS-LoginLink~">Jetzt anmelden</a>
            oder <a href="~WC-DeleteLink~">Begrüßung zurücksetzen</a>
         </p>
      </div>
   {/WC-Data}
{/WC-Active}
```

> [!WARNING]
>
> In all four examples of the previous documentation, the closing tilde is missing from `~WC-Data_LastName`. What is written there is `~WC-Data_LastName sind`, which does not result in a tag in the template but appears unchanged as text. The corrected version is shown here.

Reference: `WS-LoginLink` on the page WS- (General tags)

## The tags at a glance

| Tag | Single tag | Range tag | Negative range tag | Loop tag |
| - | - | - | - | - |
| `WC-Active` | – | yes | yes | – |
| `WC-Data` | – | yes | yes | – |
| `WC-Data_<technical field name>` | yes | yes | yes | – |
| `WC-Data_LastLogin` | yes | yes | yes | – |
| `WC-DeleteLink` | yes | – | – | – |

All tags are permitted on all templates. The field tags and `WC-DeleteLink` sensibly belong in the `{WC-Data}` range, but this is not mandatory.

## Related topics

* Reference: `WelcomeCookie` section in the shop configuration
* Guide: Login and registration
* Reference: WS- (General tags)


## Related topics

- [Customer, login, and customer account](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/kunde-anmeldung-und-kundenkonto.md)
- [$wsCookie - Browser cookies](https://dokumentation.websale.de/en/frontend/referenz/module/ws-cookie-browser-cookie.md)
- [External services and interfaces](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/externe-dienste-und-schnittstellen.md)
- [Functions](https://dokumentation.websale.de/en/frontend/referenz/funktionen.md)
- [Cookies used](https://dokumentation.websale.de/en/v8s/referenz/verwendete-cookies.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.