-1

I have a big problem to resolve. I have two php apps that connect through an LDAP. A symfony application and a docuwiki. The applications work very well independently, but I would like that when you connect to an application, you don't have to reconnect at the second. I'm not sure what solution to adopt to achieve this. Thanks for your help,

Ayoub.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 27 '21 at 08:49
  • Read this question! https://stackoverflow.com/questions/13806701/secure-and-flexible-cross-domain-sessions – Dylan Delobel Oct 27 '21 at 12:23

1 Answers1

0

I opted for another solution. I use this script to connect with the second app automatically without going through the form filling box. It works fine, but there seems to be a problem with the cookie, the session is not maintained when I change pages. An idea ? Here is the script:

<?php $path_cookie = dirname(__FILE__).'/cookie.txt';
$script = curl_init();
curl_setopt($script, CURLOPT_URL, 'XXXXXdo=login&sectok=');
curl_setopt($script, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64)');
curl_setopt($script, CURLOPT_POST, true);
curl_setopt($script, CURLOPT_POSTFIELDS, "u=XXXX&p=XXXX");
curl_setopt($script, CURLOPT_RETURNTRANSFER, true);
curl_setopt($script, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($script, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($script, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($script, CURLOPT_TIMEOUT, 120);
curl_setopt($script, CURLOPT_MAXREDIRS, 10);
curl_setopt($script, CURLOPT_COOKIESESSION, true);
curl_setopt($script, CURLOPT_COOKIEJAR, $path_cookie);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);

$connexion = curl_exec($script);

if (curl_error($script)) {
    echo curl_error($script);
}
else
{
    curl_setopt($script, CURLOPT_URL, 'XXXXX&do=admin');
    curl_setopt($script, CURLOPT_POST, true);
    curl_setopt($script, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($script, CURLOPT_SSL_VERIFYHOST, false);    
    curl_setopt($script, CURLOPT_COOKIEFILE,$path_cookie);
    curl_setopt($script, CURLOPT_POSTFIELDS, "");
    $contenu = curl_exec($script);
    curl_close($script); 
    if (curl_error($script)) {
        echo curl_error($script);
    }
    else
    {
        echo $contenu;
    }
} ?>

Thanks for your help