<p>I have a Flash application that is hosted from within a Drupal page.  Some parts of the Flash application should be available to all users, but some should only be available to a logged-in user.  (The specific role doesn't matter, just that they are any authorized user of the site).</p>

<p>From within Flash, I can detect whether the user is logged on by screen-scraping the "?q=user" page, but this is very brittle.  What is the "right" way to do this?  I can install additional Modules if necessary, but they need to be compatible with Drupal 6, not 5.</p>

<p>Similarly, if there is no user currently logged in, how can I take a username and password that they provide to me and log them in (or determine that the password is bad)?</p>

The "right" solution
you probably want to look at something like the
services module
. basically, you want to expose user services to your flash app, so you can send requests (via XML-RPC or whatever implementation you choose) to get information like "what access does the current logged in user have", or "login this user with username x and password y" etc...
The do it yourself quickly solution
if you're familiar with module development, you can create your own module quickly to just get the functionality you need, without having to go through a "real" web services layer. here's a quick example, creating a module called "myservices":
```
```
<?php
// myservices.info
   name = My Services
   description = Expose basic services
   core = 6.x

<?php
// myservices.module

   function myservices_menu() {
       $items['myservices/user'] = array(
         'title' => 'Get auth',
         'page callback' => 'myservices_get_user',
         'access arguments' => array('access content'),
       );
       return $items;
   }

   function myservices_get_user() {
       global $user;
       if (in_array('authenticated user', $user->roles) ) {
           print 'yes';
       } else {
           print 'no';
       }
   }
```
```
put those two files in a directory "myservices" in your modules directory, activate it, and then go to
```
http://yourdomain.com/myservices/user
```
if you're authenticated, it'll just return
```
yes
```
, and if not
```
no
```
, etc... which you can pick up in your flash app.