Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Feb 2005
    Posts
    74

    Default cPanel Login Fails

    I knwo it's impossible to add cronjobs using cPanel API, so I'm using curl to do it.

    The problem is, that I can't get cPanel login system working promptly. I can login to cPanel main page, but as soon as I request other cPanel pages (like cronjobs page), I'm logged out. It works *SOMETIMES*, so I believe it's something related to cPanel itself. I'm using same code for hundreds of other sites and it works perfectly. Here is the code I use:

    PHP Code:
    $cookie="cpanel_cookie.txt";


    //login to cPanel
    $ch=curl_init();
    curl_setopt($chCURLOPT_URL"http://domain.com:2082/login/?user=$cpanel_username&pass=$cpanel_password");
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($chCURLOPT_COOKIEJAR$cookie);
    curl_setopt($chCURLOPT_COOKIEFILE$cookie);
    $post=curl_exec($ch);
    curl_close($ch);

    //echo $post; //if I echo this, everything works PERFECTLY - I'm logged in!




    //add cronjob(s)

    //parse existing cronjobs first
    $ch=curl_init();
    curl_setopt($chCURLOPT_URL"http://domain.com:2082/frontend/x3/cron/advcron.html");
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
    curl_setopt($chCURLOPT_COOKIEFILE$cookie);
    $post=curl_exec($ch);
    curl_close($ch);

    //echo $post; //if I echo this, I'm NOT logged in anymore! But *SOMETIMES* it works... 
    Any ideas?

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Do you have XSRF protection(s) enabled? You can check in WHM -> Server Configuration -> Tweak Settings -> Security.

    While it's not a good idea to disable these protections, that's something that could be interfering with the functionality of your script.

  3. #3
    Member
    Join Date
    Feb 2005
    Posts
    74

    Default

    It's disabled. The most interesting part is that SOMETIMES it works correctly, and sometimes does not.

Similar Threads & Tags
Similar threads

  1. Login to /webmail works, clients login fails
    By itzhero in forum E-mail Discussions
    Replies: 7
    Last Post: 11-24-2011, 08:12 AM
  2. WHM Login Fails
    By ManXP in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 05-04-2009, 10:17 AM
  3. cPanel login with correct password fails
    By stealthlainry in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 01-08-2008, 01:19 PM
  4. cPanel login fails
    By RField9 in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 06-22-2007, 05:27 AM
  5. Frontpage Login Fails - Please Help!
    By aplustechs in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 11-25-2005, 10:51 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube