I made a simple PHP login system to login remotely, but the SESSION won't store any data. Please look at the pseudo code below. Please note that mainserver and remoteserver are actually real web addresses. I just don't have enough reputation to post 2 links:
File: mainserver/login.php
$username = $_POST[ "username" ];
$userpassword = $_POST[ "password" ];
$result = check_logIn( $username, $password );
if ( $result ) {
$_SESSION[ "is_loggedIn" ] = true;
die ( true );
} else die( false );
File: remoteserver/remoteLogin.php
$http_query = http_build_query( array(
"username" => "Username goes here",
"password" => "Password goes here"
) );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL,"mainserver/login.php");
curl_setopt( $ch, CURLOPT_COOKIEJAR, md5( rand() ) .".txt" );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $http_query );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec ( $ch );
curl_close( $ch );
Even when the mainserver returns true (after the login was done successfully), I visit the http://mainserver.com/ but the $_SESSION[ "is_loggedIn" ] is still not there; and technically, I'm still treated as a logged out person.
Is there anything missing that I should address?