A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Check if logged in in joomla

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    38

    Check if logged in in joomla

    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 )
    Last edited by panoss; 05-30-2013 at 10:40 AM.

  2. #2
    Member
    Join Date
    Aug 2008
    Posts
    38
    Well, the solution was right in front of my eyes :
    I had to run the html file that automatically flash produces (in which is embedded the swf file), and not the swf file...:
    http://localhost/das/getUsername.html

    Works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center