Child pages
  • UAPI Functions - Session::create_temp_user
Skip to end of metadata
Go to start of metadata

Description

This function creates a temporary user session. 

Important:

  • Because this function requires a valid cPanel session ID, you must call it via a cPanel or Webmail session URL. If you call this function via the command line or Template Toolkit, it will not create a temporary user session. You must use the WHM API 1 create_user_session function to create a temporary user session.
  • Third-party plugins that require access to temporary MySQL users must call this function via the URL. It will create the temporary users before they are available. You can find these users in the $ENV{'REMOTE_DBOWNER'} environment variable.
  • If you cannot update your system, update your scripts to call the Cgi::phpmyadminlink function. This will create a temporary user session for you.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Session/create_temp_user


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Create a temporary session.
$create_session = $cpanel->uapi(
    'Session', 'create_temp_user'
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Create a temporary session.
my $create_session = $cpliveapi->uapi(
    'Session', 'create_temp_user',
);


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit

Important:

If you call this function via the Template Toolkit, it will not create a temporary user session. You must use the WHM API 1 create_user_session function to create a temporary user session.


Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line

Important:

If you call this function via the command line, it will not create a temporary user session. You must use the WHM API 1 create_user_session function to create a temporary user session.

 Output (JSON)
{
    "apiversion":3,
    "module":"Session",
    "func":"create_temp_user",
    "result":{
        "status":1,
        "warnings":null,
        "metadata":{

        },
        "data":{
            "created":0
        },
        "errors":null,
        "messages":null
    }
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
createdBooleanWhether the function successfully created the temporary user session.
  • 1 — Success.
  • 0 — Failure.
1
session_temp_userstring

The temporary user's session ID.

A valid string.

cpses_reviY3ZSQK