# SSO code examples

### PHP

```html
<html><body>
<script>
<?php
if (!$_REQUEST['logoff']) {
        $profile = array(
            // Example values used. Replace with your customer and app details

                'appClientId' => "my-cool-app", 
                'userId' => "234",
                'profile' => array(
                        'email' => "test@example.com",
                        'billingPerson' => array(
                                'name' => "Tester",
                                'companyName' => "Company Name",
                                'street' => "Street",
                                'city' => "City",
                                'countryCode' => "US",
                                'postalCode' => "10001",
                                'stateOrProvinceCode' => "NY"
                        )
                )
        );
        $client_secret = "A1Lu7ANIhKD6A1Lu7ANIhKD6ADsaSdsa";    // this is an example client_secret value
        $message = json_encode($profile);
        $message = base64_encode($message);
        $timestamp = time();
        $hmac = hash_hmac('sha256', "$message $timestamp", $client_secret);   
        echo "var ecwid_sso_profile='$message $hmac $timestamp'";
} else {
        echo "var ecwid_sso_profile=''";
}
?>
</script>
<script src="http://app.ecwid.com/script.js?1003"></script>
<script>
xProductBrowser();
function logout() {
        window.Ecwid.OnAPILoaded.add(function() {
                window.Ecwid.setSsoProfile('');
        });
}
</script>
<a href="javascript: logout()">Log out</a>
</body></html>
```

### VB.Net

Find an example here: <https://github.com/balajiselcom/Ecwid> (thanks to Balaji Sridharan)

### Wordpress

Ecwid official Wordpress plugins uses SSO to sync Wordpress site users with customers in an Ecwid store. You can find the code here: <https://github.com/Ecwid/ecwid-wordpress-plugin>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ecwid.com/api-reference/rest-api/storefront-widget-details/sso-single-sign-on-for-websites/sso-code-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
