How to Generate the Session Id in Salesforce?





  • Open Developer Console
  • Click on Debug Tab
  • Click on Open Execute Anonymous Window (CTRL+E)
  • Paste the below Code and Highlight with the those two lines
  • Check the Open Log checkbox
  • Click on Execute Highlighted button then click on Debug only check box
  • Copy the Session Id and use it.

String sessionId = UserInfo.getOrganizationId()+''+UserInfo.getSessionId().SubString(15);
System.debug('https://orgName.lightning.force.com/secur/frontdoor.jsp?sid='+sessionId);
Note: Replace orgName with your domain and run in the developer console.

Happy Coding!!!