This article is particularly relevant to you if you are creating a SharePoint app using JavaScript and the Client side object model. In the development of such an app, we would require some basic properties- SharePoint provides these with the _spPageContextInfo object.

_ spPageContextInfo will provide these below properties:
  •  webServerRelativeUrl
  •  webAbsoluteUrl
  • siteAbsoluteUrl
  • serverRequestPath
  • layoutsUrl
  • webTitle
  • webTemplate
  • tenantAppVersion
  • isAppWeb
  • webLogoUrl
  • webLanguage
  • currentLanguage
  • currentUICultureName
  • currentCultureName
  • env
  • nid
  • fid
  • clientServerTimeDelta
  • updateFormDigestPageLoaded
  • siteClientTag
  • crossDomainPhotosEnabled
  • webUIVersion
  • webPermMasks
  • pagePersonalizationScope
  • userId
  • userLoginName
  • systemUserKey
  • alertsEnabled
  • siteServerRelativeUrl
  • allowSilverlightPrompt
  • themedCssFolderUrl
  • themedImageFileNames


You can also access this object in JavaScript model as:

<script type="text/javascript">
var propertyValue = _spPageContextInfo.PropertyName


Get current login user name

<script type="text/javascript">
var loginName = _spPageContextInfo.userLoginName

The above example will show an alert of value current user login.
To check the properties and its value of _spPageContextInfo, browse a SharePoint web page and open its view source (HTML - right click on web page ? view page source) and find text "spPageContextInfo".

See below screenshot: