How To Get Session Id In Salesforce

Session Id is used to identify a user using salesforce UI or API tools, it has a time limit and can be manually expired by the user logging out or by an admin removing that session in Setup.

Today, We are going to see how we can get the session Id using Apex through Anonymous Window. Let's go through and understand how can we get the session URL. 

Also Read: How to Get the Session Id of Current User in Lightning Web Component

By using getSessionId method of UserInfo class, we can get the session id in our apex code. Here we are going to learn how to create a session id in salesforce.

Step 1: Open Developer Console. Click on Debug and click on Open Execute Anonymous Window.

Step 2: Copy the below code.
Step 3: In Anonymous Window, Paste that code and click on the Open Log checkbox and Execute.
Step 4: Now, We will get logs. Click on Debug Only checkbox.
Step 5: Double-click on the first line.
Step 6: Copy the URL as shown below and paste it to another browser and it will open your org directly.

That's all for today. Still, if you have any further suggestions, thoughts, and questions, then just make sure to comment down.

Comments