Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function creates a temporary user session. In earlier versions of cPanel & WHM, the system created temporary MySQL®/MariaDB users whenever a user logged in to cPanel via external session creation instead of password authentication. This caused high load and performance issues on systems with frequent logins.

As of cPanel & WHM version 54, the system no longer created temporary users for external session logins until a script or user accessed the phpMyAdmin feature or the backup functionality.

Third-party plugins that require access to temporary MySQL users (found in $ENV{'REMOTE_DBOWNER'}) will now need to call the Session::create_temp_user function in order to create the temporary users before they are available.

Important:

If you cannot update your system for whatever reason, the workaround is to update your scripts to call cPanel API 1 Functions - Cgi::phpmyadminlink , which 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
<!-- Create a temporary session. -->
[% data = execute( 'Session', 'create_temp_user' ); %]

Note:

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

 

 Command Line
uapi --user=username Session create_temp_user

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{ 
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

   },
   "data":{  
      "created":1,
      "session_temp_user":"cpses_reviY3ZSQK"
   }
}


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