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

# WebView configuration

> Program × Developer: WebView setup and opening URL parameters for embedding the Paylead WebApp (MFP).

Correct cookie and WebView configuration is what keeps the [SSO flow](/program/webapp/authentication)
working without showing the authentication screen on every open.

<Tip>
  ### Golden rule

  All steps of the flow (pre-check, authentication, callback, opening) must run in
  **the same WebView**, with **the same cookie jar**.
</Tip>

### User-Agent identification (required)

The mobile app must keep the device's default User-Agent and **append** a
`PayleadWebView` suffix at the end.

<Check>**Purpose**: let Paylead reliably identify that the navigation comes from a
WebView embedded in the mobile app</Check>

```text Example User-Agent theme={null}
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 PayleadWebView
```

<Danger>
  Do **not** replace the whole User-Agent. Replacing it breaks Paylead's ability
  to identify the WebView and can lead to hard-to-diagnose support issues. Only
  append the `PayleadWebView` suffix.
</Danger>

### Platform setup

<Tabs>
  <Tab title="iOS (WKWebView)">
    Use the default (persistent) data store and reuse the same WebView instance.

    ```swift Configuration theme={null}
    let config = WKWebViewConfiguration()
    config.websiteDataStore = .default() // not .nonPersistent()
    let webView = WKWebView(frame: .zero, configuration: config)
    ```

    * Reuse the same instance across opens.
    * Verify that `.paylead.eu` cookies persist:

    ```swift Cookie check theme={null}
    webView.configuration.websiteDataStore.httpCookieStore.getAllCookies { cookies in
        // verify presence
    }
    ```
  </Tab>

  <Tab title="Android (WebView)">
    Accept cookies, including third-party cookies, and keep the WebView alive.

    ```kotlin Configuration theme={null}
    val cm = CookieManager.getInstance()
    cm.setAcceptCookie(true)
    cm.setAcceptThirdPartyCookies(webView, true)
    ```

    * Do not recreate the WebView on each open.
    * Do not call `clearCache(true)` or `clearFormData()` before loading.
    * Keep the same instance alive for the whole flow.
  </Tab>
</Tabs>

### Server-side cookie attributes

The Paylead session cookies are issued with the following attributes:

* `Domain` = `.paylead.eu`
* `Path` = `/`
* `HttpOnly` = `true`
* `Secure` = `true`
* `SameSite` = `None` (required in a WebView)

<Tip>
  **Going further:** the full list of cookies used by the WebApp (names,
  purpose, lifetimes) is documented on the
  [Cookies](/program/webapp/cookies) page.
</Tip>

## Opening URL parameters

The WebApp reads two optional URL parameters at startup, before the interface initialises. Pass them in the opening URL to control the display language and visual theme.

### `lang` — Display language

Append `?lang=<code>` to the opening URL.

The WebApp selects a language using the following priority order:

1. The `lang` URL parameter, if present.
2. The language last saved in the user's browser storage.
3. The language detected from the browser's `Accept-Language` header.
4. French (`fr`) as the fallback.

The selected language is saved in the user's browser. On subsequent opens without a `lang` parameter, the saved value applies.

| Code | Language | Availability    |
| ---- | -------- | --------------- |
| `fr` | French   | All themes      |
| `en` | English  | Theme-dependent |
| `nl` | Dutch    | Theme-dependent |
| `de` | German   | Theme-dependent |

<Note>
  Available languages depend on the theme configured for each client. An unsupported code falls back to French.
</Note>

### `mode` — Visual theme

Append `?mode=<value>` to the opening URL.

| Value   | Effect      |
| ------- | ----------- |
| `light` | Light theme |
| `dark`  | Dark theme  |

The parameter is applied on load and is not saved between sessions. Pass it on every open if the host app controls the visual theme.

<Note>
  Dark mode is only available for clients whose theme has been configured to support it. For other clients, the parameter is silently ignored and the WebApp displays in light mode.
</Note>

### Example

```text theme={null}
https://consumer-<reference_pm>.paylead.eu?lang=en&mode=dark
```

## What's next

<CardGroup cols={2}>
  <Card title="Cookies" icon="cookie" href="/program/webapp/cookies">
    The cookies the WebApp sets, their purpose, and scope.
  </Card>

  <Card title="Mobile Bridge" icon="cable" href="/program/webapp/bridge/overview">
    How the WebApp calls native capabilities from inside your WebView.
  </Card>
</CardGroup>
