WHM API 1 Functions - create_user_session

Description

This function creates a new temporary user session for a specified service. This allows users with WHM access (with a password or access hash) to log in to third-party applications, such as billing systems, without the need to store the account password.

Notes:

  • The system destroys the temporary session after 15 minutes of inactivity.
  • For more information about the Single Sign On feature, read our Guide to API Authentication documentation.

Examples


 JSON API

https://hostname.example.com:2087/cpsess##########/json-api/create_user_session?api.version=1&user=username&service=cpaneld&locale=fr&app=awstats

 XML API

https://hostname.example.com:2087/cpsess##########/xml-api/create_user_session?api.version=1&user=username&service=cpaneld&locale=fr&app=awstats

 Command Line

whmapi1 create_user_session user=username service=cpaneld locale=fr app=awstats

 Output (JSON)

{
  "data": {
    "cp_security_token": "/cpsess1234567890",
    "expires":1401993893,
    "session": "username:GHehYZ1GCxzmDATMmT1xT4rN0tiPGMWnKErPJdU3t6AGBx2LjQ3qB6Xih5naUh_4:create_user_session,
    5dc619831bac4aa2e014e062d762645e8447949eaef14fc53a8ce2b1e0e2592a",
    "url":
"https://example.com:2083/cpsess1234567890/login/?
    goto_uri=frontend%2fx3%2fstats%2fawstats_landing.html&locale=fr&session=username:%3aGHehYZ1GCxzmDATMmT1xT4rN0tiPGMWnKErPJdU3t6AGBx2LjQ3qB6Xih5naUh_4%3acreate_user_session%2c5dc619831bac4aa2e014e062d762645e8447949eaef14fc53a8ce2b1e0e2592a",
    "locale":"fr"    
    "service": "cpaneld"
  },
  "metadata": {
    "version": 1,
    "reason": "Created session",
    "result": 1,
    "command": "create_user_session"
  }
}

 Output (XML)

<result>
    <data>
        <session>
            username:RFw6MUp9S8sRwTSgqaUJWUCq8ZQg2Zkopx5KaTHRNQXBfT3n8xvfBEF9JJC3iiwa
        </session>
        <expires>1401993893</expires>
        <url>
            https://example.com:2083/cpsess1234567890/login/?session=username:RFw6MUp9S8sRwTSgqaUJWUCq8ZQg2Zkopx5KaTHRNQXBfT3n8xvfBEF9JJC3iiwa&locale=fr&app=awstats
        </url>
        <service>cpaneld</service>
        <cp_security_token>/cpsess1234567890</cp_security_token>
    </data>
    <metadata>
        <reason>Created session</reason>
        <version>1</version>
        <result>1</result>
        <command>create_user_session</command>
    </metadata>
</result>

 

Note:

Use WHM's API Shell interface (Home >> Development >> API Shell) to directly test WHM API calls.

     

Parameters

 Parameter 

Type

Description

Possible values

 Example 

user

string

Required

The session's user.

A valid cPanel account's username. 

user

service

string

Required

The session's service.

  • cpaneld
  • whostmgrd — Available in cPanel & WHM version 11.44+ only.
  • webmaild — Available in cPanel & WHM version 11.44+ only .

cpaneld

locale

 string 

The session's locale.

If you specify a locale, the server sends a cookie to your browser with that locale setting.

  • The cookie expires after one year. 
  • Users can change the locale with the language options at the bottom of the login interface.

A valid locale abbreviation.

fr

app

string

The application to which the session will link.

Note:

 cPanel & WHM version 11.50 added this parameter to allow WHM users to directly access an application's interface as the specified cPanel user. 

  • One of the following valid application names, to link the session to an application:
    •  
    • Backups_Home
    • Calendar_Configure
    • ContactInfo_Change
    • Cron_Home
    • Database_MySQL
    • Database_phpMyAdmin
    • Domains_AddonDomains
    • Domains_SubDomains
    • Email_AccountLevelFiltering
    • Email_Accounts
    • Email_Archive
    • Email_Authentication
    • Email_AutoResponders
    • Email_BoxTrapper
    • Email_DefaultAddress
    • Email_DeliveryReport
    • Email_Forwarders
    • Email_GreyListing
    • Email_MailingLists
    • Email_MX
    • Email_SpamFilter
    • Email_UserLevelFiltering
    • FileManager_Home
    • Locale_Change
    • Password_Change
    • Site_Software
    • Site_Software_*
    • Stats_AWStats
    • WHMCS_billing
  • An invalid application name, to create the session but not link it to an application. 

awstats

 

Returns

Return

Type

Description

Possible values

Example

session

string

The session ID.

The cPanel account username, a colon, and a unique string of characters. 

 

service

string

The security token's service.

  • cpaneld
  • whostmgrd
  • webmaild

cpaneld

 cp_security_token 

 string 

The session's security token.

A valid string.

 /cpsess1234567890 

expires

string

 The date when the security token expires. 

A valid date in Unix time format.

1401993893

url

string

The security token's URL.

A valid URL that contains the session or app values.

Note:

 In cPanel & WHM version 11.50 and later, if the appparameter contained a valid application, this URL contains application information. 

 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....