Jump to content

How to create a curl login into backend and frontend


Recommended Posts

Hi everyone,

 

I am using prestahop v.1.5.2 and last few days I am trying to make a curl login into backend (later must create a login to frontend) but with no success. :(

 

I have a custom site with user login area and prestashop in subfolder of my site. I want to "merge" the users and create а script which must set the cookies for prestashop (I have already created the existing users in mysite on prestashop).

 

I have created a script but doesn`t work, there is no cookie set from prestashop for the user.

 

Where is the problem, is there any other solution of my idea. :blink:

 

This is my script:

 

<?php
$login_url = 'path_to_site/shop/admin_test/login.php';
$email="user_mail";
$passwd="user_pass";
//$post_fields    = 'passwd='.urlencode($passwd).'&email='.urlencode($email);
$datatopost = array(
'password' => $passwd,
'email' => $email
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$info = curl_getinfo($ch);
$returndata = curl_exec ($ch);
curl_close($ch);
?>

Link to comment
Share on other sites

  • 9 months later...
×
×
  • Create New...