> ## 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.

# Session

> Reference for WEBSALE session actions: write session variables and unlock a locked session after a failed payment or checkout attempt.

This section describes the available session actions. With these actions, session variables can be written or a locked session can be unlocked again after a failed payment process, for example.

***

## Actions overview

| **Action**      | **Description**                                            |
| --------------- | ---------------------------------------------------------- |
| `SessionUpdate` | Writes a value to a session variable.                      |
| `SessionUnlock` | Unlocks the session after a failed online payment process. |

***

## Actions

### SessionUpdate

This action writes a value to a session variable. The variable is addressed via the parameter name `session.(variableName)`, where `variableName` stands for the desired key within the session.

**Usage example**\
Useful for storing user-defined state information in the session during the user experience, e.g., a selected filter, progress in the checkout, or a temporary note that should be available across pages.

**Parameters**

| **Name**                 | **Description**                                      |
| ------------------------ | ---------------------------------------------------- |
| `session.(variableName)` | The key and value of the session variable to be set. |

**Related modules, variables & methods**

* [\$wsSession](/en/frontend/referenz/module/wssession)
* [\$wsSession.set()](/en/frontend/referenz/module/wssession#\$wssession-set)
* [\$wsSession.get()](/en/frontend/referenz/module/wssession#\$wssession-get)

**Example** showing how a value is written to a session variable and then read out.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionSessionUpdate = $wsActions.create("SessionUpdate") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionSessionUpdate.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionSessionUpdate.id }}">
    <input type="hidden" name="session.lastViewedCategory" value="Running shoes">
    <button type="submit">Save.</button>
</form>

{{ if $wsSession.get("lastViewedCategory") }}
    Category: {{= $wsSession.get("lastViewedCategory") }}
{{ /if }}
```

***

### SessionUnlock

This action unlocks a locked session. A session can enter a locked state after a failed online payment process to prevent unintended follow-up actions. `SessionUnlock` resets this lock state so the customer can restart or continue the process.

This action expects no parameters and returns no error responses.

**Usage example**\
Can be used on an error or return page after a failed payment process to enable the customer to retry the payment or select another payment method.

**Related modules, variables & methods**

* [\$wsSession](/en/frontend/referenz/module/wssession)
* [\$wsSession.isLocked](/en/frontend/referenz/module/wssession#\$wssession-islocked)

**Example** showing how a customer with a locked session is given the option to unlock it via a button.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ if $wsSession.isLocked }}
    {{ var $myActionSessionUnlock = $wsActions.create("SessionUnlock") }}
    <form method="post" action="{{= $wsViews.current.url() }}">
        <input type="hidden" name="wscsrf" value="{{= $myActionSessionUnlock.csrf }}">
        <input type="hidden" name="wstarget" value="{{= $wsViews.current.url() }}">
        <input type="hidden" name="wsact" value="{{= $myActionSessionUnlock.id }}">
        <button type="submit">Unlock session.</button>
    </form>
{{ /if }}
```
