<?php
session_start();
$uid=$_SESSION['userIdsession'];
//pass the uid as a command-line parameter
$command = '/usr/bin/php -f /path/to/test.php '. $uid;
exec( "$command > /dev/null &", $arrOutput );
?>
test.php
<?php
$uid=$argv[1];
$to = 'xxx@gmail.com';
$subject ='dd'.$uid;
$message='Some Message';
//be sure to include a "From:" headers. Some mailers will not send out emails if you don't have a From header.
$headers="From: you@yourcompany.com\n";
mail($to,$subject,$message,$headers);
?>
<?php
echo `which php`;
$command = '/usr/bin/php -f /home/mywebsite/public_html/test.php ';
/* exec( "$command > /dev/null &", $arrOutput ); */
exec( "$command ", $arrOutput );
print_r ($arrOutput);
?>
<?php
// test.php already calls session_start()
include ('test.php');
?>