---
schema_version: "1"
id: a0ecf63a6e88b94ce3f727f32fece5d00bd6e3378d7d0174edbddda3f4d40c01
title: "Step 4: Write Login and Logout Functions"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/external_identity_login_step_4.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.external_identity_login_step_4.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 1ed48a1544b565ddfddba852d22f08706bb9168398d41af5a5550efa8f0f2a8b
description: On the web page, provide a login and optional logout JavaScript function in the body to handle onLogin and onLogout events. With these functions, you determine what happens when users log in and out successfully. You have full control over what happens.
products:
  - Security
  - Cross Cloud
release: "264"
---
# Step 4: Write Login and Logout Functions

On the web page, provide a login and optional logout JavaScript function in the body to handle `onLogin` and `onLogout` events. With these functions, you determine what happens when users log in and out successfully. You have full control over what happens.

![Warning](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-identity-264-0-0-production-enus/699dab6f-8f1a-4662-b24f-6521d5b747f7/images/icon_warning.png)

Warning In Summer ’24, Salesforce made Embedded Login disabled by default. We recommend that you use the [web server flow](https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_oauth_web_server_flow.htm&type=5&language=en_US), the [user-agent flow](https://help.salesforce.com/s/articleView?id=xcloud.remoteaccess_oauth_user_agent_flow.htm&type=5&language=en_US), or another redirect-based OAuth 2.0 flow instead of Embedded Login.

Embedded Login relies on third-party cookies, which are blocked or restricted in most browsers. And Embedded Login works only on Google Chrome and only as long as third-party cookies are allowed there by default.

1. Add a login function to the body of the web page.
2. Optionally, add code to the login function to retrieve user information from Salesforce.
3. Optionally, add a logout function to the body of the web page.