shahram mohseni

Registered
Mar 7, 2017
4
0
1
tehran
cPanel Access Level
Website Owner
I try to login usin Curl, everything must be ok but finally it says like security token xyz is invalid and then i have to manually click the login button to continue. bellow is the final link it stops:
Code:
http://www.example.ir:2082/cpsess0807585904/frontend/paper_lantern/index.html?login=1&post_login=2531456137975
my guess is i don't know what real path to save the cookie!
any idea please how to solve this login using curl ? this is my code:
Code:
function createSession() { // Example details
$ip = "127.0.0.1";
$cp_user = "myUser";
$cp_pwd = "myPass";
$url = "http://www.example.ir:2082/login";
$cookies = "cookies.txt";

// Create new curl handle
$ch=curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies );
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies ); // Save cookies to
curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$cp_user&pass=$cp_pwd");
curl_setopt($ch, CURLOPT_TIMEOUT, 100020);

$f = curl_exec($ch);
$h = curl_getinfo($ch);
curl_close($ch);

$luckyUrl = $h['url'];
// If we had no issues then try to fetch the cpsess
if ($f == true and strpos($h['url'],"cpsess"))
{
    // Get the cpsess part of the url
    $pattern="/.*?(\/cpsess.*?)\/.*?/is";
    $preg_res=preg_match($pattern,$h['url'],$cpsess);
}

header("Location: ".$luckyUrl);
// If we have a session then return it otherwise return empty string
return (isset($cpsess[1])) ? $cpsess[1] : "";

}
echo createSession();
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
Hello,

Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

Thank you.
 

shahram mohseni

Registered
Mar 7, 2017
4
0
1
tehran
cPanel Access Level
Website Owner
I am new to this site and understanding this site is really difficult .. i don't understand your words technically , i went to support menu to open a ticket but it did not accept my user pass which i'm using now !! then where is your signature and what is the way to use the link in it to open a support ticket ?? please do it yourself if possible, i just need the answer to main question and not such a long process man! thanks in advance .
 

shahram mohseni

Registered
Mar 7, 2017
4
0
1
tehran
cPanel Access Level
Website Owner
holy God ! the exact user pass i use to login and post here , but can't login to the ticket login ara you gave me !! let's remind I am free user i mean just simply some days ago created this account .. any way if possible please someone on behalf of me do post and do ticket this exact question in the area u need .. i don't understand why not answer here, but if necessary please someone do post and do ticket it . then me and many people will see the answer ..

question was: with codes on top of this page i try to login to cpanel easily, but finally cpanel tells me '' The security token in your request is invalid.''
my guess is that i don't know the real path to save the $cookie ! for example is it /home/myusername/cookie or what ?
on the other hand this could be due to anything else.. is there a simple solution to this please ..?
 

shahram mohseni

Registered
Mar 7, 2017
4
0
1
tehran
cPanel Access Level
Website Owner
what ? i logged into ticket panel finnnaly and now what a mess there.. hhhhh are u kidding me /
i go to stackovechange or somewhere else to find the answer , even if couldn't find the anwer better i take it easy and forget it..
if sombody knows the answer to this easy question please post it here .. bye .
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
i logged into ticket panel finnnaly and now what a mess there.
Hello,

A support ticket allows us the ability to access the system to get a better idea of what's happening. We're happy to help guide you through the ticket creation process. Which particular step are you having trouble with?

Thank you.