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.

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


https://hostname.example.com:2083/cpsess##########/execute/Session/create_temp_user

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

 

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',
);

 

<!-- Create a temporary session. -->
[% data = execute( 'Session', 'create_temp_user' ); %]

 

uapi --user=username Session create_temp_user

{ 
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

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

   

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