I'm trying to setup a login system using ajax.
After the user inserts his login and password in subdomain.domain.com (which could also be otherdomain.com) I make a Jquery $.post request to rest.domain.com and the user gets properly logged in.
Then, if I make another request to rest.domain.com to check if the user is logged (or to make other operations that required the user to be logged in) the session is empty.
What am I doing wrong?
EDIT
Client app
$.post('http://rest.domain.com/user/login',form,function(data){
//Do what is needed
});
RESTful app (using Slim and uFlex)
header('Access-Control-Allow-Origin: *');
session_start();
//User
//Check if logged
$app->get('/user/logged', function () use ($user, $app){
print_r($_SESSION);
echo $user->signed;
});
//Login
$app->post('/user/login', function () use ($user, $app) {
$username = isset($_POST['email']) ? $_POST['email'] : false;
$password = isset($_POST['password']) ? $_POST['password'] : false;
$auto = isset($_POST['auto']) ? $_POST['auto'] : false;
$user->login($username,$password,$auto);
if($user->signed){
print_r($_SESSION);
}else{
//Display Errors
foreach($user->error() as $err){
echo "<b>Error:</b> {$err} <br/ >";
}
}
});