I 'm making a flash 8 application, where I'm trying to check if the user is logged in in my joomla site.
This is my code in flash:
Code:
submit_button.onRelease = function()
{
submitURL = "http://localhost/das/getUsername.php";// my testing purpose
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean)
{
if (success)
{
result_ta.text = "We are in business.... " + this.result;
}
else
{
result_ta.text = "Error connecting to server.";
}
};
send_lv = new LoadVars();
send_lv.sendAndLoad(submitURL,result_lv,"POST");
};
This is getUsername.php on my localhost:
PHP Code:
<?php
//Load Joomla environment
if (! defined('_JEXEC'))
define('_JEXEC', 1);
$siteroot = $_SERVER['DOCUMENT_ROOT'];
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', $siteroot);
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once JPATH_BASE .DS.'includes'.DS.'framework.php';
jimport( 'joomla.environment.request' );
JFactory::getApplication('site')->initialise();
$user = JFactory::getUser();
if (!$user->guest) {
// user is logged in
echo("&result=yes");
die();
} else {
// user is not logged in
echo("&result=no");
}
When I call the getUsername.php from the browser, works correctly.
But when I 'm running the Flash code, it always returns me 'result=no', even when the user is logged in!
What's wrong?
(It's allready 2 days that I've spent over this, my head is dizzy )