Saturday 01 October 2022

Technical solutions


Technical information by Francois

The form is installed, but the redirection doesn’t work (or redirects to another webpage)

Amongst reasons causing a problem during the redirection, domain changes can be one of them: the authentication on the site is made on a particular domain ( whereas the redirection is made on another domain where the authentication is lost ( The problem can be solved either in defining explicitly the cookies on a group of domains, or in making redirections to be sure that the authentication and the redirection are still matching.

There are several possible solutions to this common problem :

  • You make sure that the authentification occurs on the same domain as the redirection page (protected).
  • It is possible to change the session cookies domain so that they consider all the sub-domains either in configuring the php.ini (session.cookie_domain), or in calling session_set_cookie_param
// To call before session_start so that the right parameters are considered

Another reason which can cause a problem during the redirection: the allow_url_fopen directive turned to ‘Off’. If your host doesn’t want to modify it, a solution exists: the use of the cURL() method instead of file() in the protection script.

$url = '';
$url .= 'docId='.$docId; 
$url .= '&siteId='.$siteId;  
$url .= '&code='.$_GET['code'];  
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // time out 10 seconds
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
$result = curl_exec($ch);
$result = trim($result);
$pos = strpos($result,'OK');

if ($pos === false) {
// error
// ok