Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran
Last active June 17, 2019 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsomasundaran/efbb1f5215a0fe1373289062a34d0a34 to your computer and use it in GitHub Desktop.
Save anilsomasundaran/efbb1f5215a0fe1373289062a34d0a34 to your computer and use it in GitHub Desktop.
<apex:page controller="LexSessionController">
Start{!$Api.Session_ID}End
</apex:page>
public class LexSessionController {
public static String fetchUserSessionId(){
String sessionId = '';
// Refer to the Page
PageReference sessionIdPage = Page.LexGetSessionIdPage;
// Get the content of the VF page
String vfContent = sessionIdPage.getContent().toString();
// Find the position of Start and End
Integer startPosition = vfContent.indexOf('Start') + 'Start'.length(),
endPosition = vfContent.indexOf('End');
// Get the Session Id
sessionId = vfContent.substring(startPosition, endPosition);
System.debug('sessionId '+sessionId);
// Return Session Id
return sessionId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment