Get Salesforce Session Id in Visualforce Page And Apex Class

Visualforce Page:

{!$API.Session_ID}

Apex Class:

String sessionId = UserInfo.getOrganizationId()+''+UserInfo.getSessionId().SubString(15);