How do I add a global variable to my app?

Hi all,
I am building a flex app which displays data in different tabs from a mysql database and I wan't to add a sign in process to make sure only registered users of the mysql db can see the data.
To achieve this I built a sign in component which accepts a username, password and the name of the database to connect to. My flex app then uses a php script to verify that the user can connect to the database using the details entered. If not, the sign in component displays an error message, but if sign in details are verified then the user can see the data from the database.
How can I store the details in the flex app for that users session so that when the user queries the db for data, flex uses the details entered during the sign in process to connect to the mysql db and submit the query?
I thought about storing the details as an array in a global variable and then accessing that global variable from anywhere in my app but I don't know if that is the correct/secure way to do what I want, nor do I know how to do it. Any help would be much appreciated.
Thanks in advance,
xander

quick, dirty example, could be improved on but it'll get you rolling;
After user login has succeeded, send off another HTTP service eg;
========
<mx:Script>
         <![CDATA[
            public var whateverUserNameWasEntered:String;
             public var whateverUserPasswordEntered:String;
     public function onLoginSuccess():void
          whateverUserNameWasEntered:String = loginbox.text;
          whateverUserPasswordEntered:String = passwordbox.text;
          storeSessionStuff.send();
     ]]>
    </mx:Script>
<mx:HTTPService id="storeSessionStuff" showBusyCursor="true" method="POST"  url="http://localhost/store.php" useProxy="false">
        <mx:request xmlns="">   
          <username>
               {whateverUserNameWasEntered}
          </username>
          <password>
               {whateverUserPasswordEntered}
          </password>       
        </mx:request>
    </mx:HTTPService>          
========
direct it to the php file.....
<?php
session_start();
$_SESSION['username'] = $_POST['username'];
$_SESSION['password']   = $_POST['password'];
?>
Then, whenever you want to get the information out of the Session, send off another HTTP Service...;
<mx:HTTPService id="getSessionStuff" result="storeData(event)" showBusyCursor="true" method="POST"  url="http://localhost/get.php" useProxy="false"/>
to the php file....
<?php
session_start();
print "<details><username>".$_SESSION['username']."</username><password>".$_SESSION['password'] ."</password></details>";
?>
which, you need a result function for:
<mx:Script>
         <![CDATA[
          private function storeData(evt:ResultEvent):void
                var username:String;
                var password: String;
               username = evt.result.details.username;    
               password = evt.result.details.password;         
      ]]>
</mx:Script>
ta daa
(if thats what you meant)

Similar Messages

  • How to auto create a global variable with specific variable name in a global vi ?

    how to auto create a global variable with specific variable name in a global vi using lv ? Because i need to add a lot of global variable in this global vi. But you know, if  i manually add them , it will be a much time-costing work. So i want to use someway to auto generate ? Can i ?? Thanks a lot !

    Hi
    what aartjan is saying is the way for you. but you can develop an utility which will actually help you create global variables. To get the details on this just have a look at VI Scripting section on LAVA forum.
    But i would like you to suggest few things
    1. If your programs have so many global variables (Thats why u want utility) then you should take out some time to read about LabVIEW design patterns. I think if programmer follows these practicess he dont need a single global variable.
    2. Their are some other ways to achieve similar functionality as of global variables (Uninitialized Shift Registers, Single Element Qs and so on) but they are much faster than global variables.
    I am Attaching Whatever Resources i am having I will also attach the template of the design pattern i generaly use in short duration
    Message Edited by Tushar Jambhekar on 10-06-2005 07:33 PM
    Message Edited by Tushar Jambhekar on 10-06-2005 07:36 PM
    Tushar Jambhekar
    [email protected]
    Jambhekar Automation Solutions
    LabVIEW Consultancy, LabVIEW Training
    Rent a LabVIEW Developer, My Blog
    Attachments:
    LabVIEWDesignPatterns.zip ‏1505 KB
    Large_Code_Implementation.zip ‏522 KB
    Database Tests.zip ‏868 KB

  • How can we deinitialize the global variable........?

    how can we deinitialize the global variable........?

    It would possibly be more performant to...
    DBMS_SESSION.MODIFY_PACKAGE_STATE (DBMS_SESSION.REINITIALIZE);
    Bearing in mind that reinitialize is not exactly the same thing as deinitialize ;-)

  • How does one add folders to the E-mail App?

    How does one add folders to the E-mail App?

    Select your email under Account, tap Edit at the top then New Mailbox at the bottom. This will only work if you have an IMAP email account.

  • How can i find all global variable and parameters in a form?

    I don't know name of global variables and parameters,but i want get their name and value .
    how can i do? who can help me?
    Thank you.
    Daniel Liang
    2007.1.19

    no problem. As Francois said you can't do it programmatic in runtime.
    But when you use the debug-mode you can see each global with name and value.
    By the way: It's not good to not know all the globals in your application. This is one of the most important things you have to write down for your app. Create a wiki for such informations, so that all developer can share their information.

  • How to create and access Global variable in Microsoft Lightswitch(VB)?

    How to create an integer datatype Global variable in Microsoft Lightswitch 2011(VB) and access it in pre-process query to set value? Can it be accessed and set like Me.Application.<MyGlobalVariable> = 999
    Thnx.
    jajjaar123

    If you want to create integer datatype Global variable in lightswitch, you can refer to (Eric Erhardt) blog
    Create and Use Global Values In a Query

  • How can I add one seat for a single app to a team account?

    We currently have a team for our art department, which needs Photoshop, Illustrator, In Design and Acrobat.  We have other departments that just need Acrobat.  How can I add one seat, that has access to only one App so I'm not paying the full price?

    Did you ever figure this out? I need Photoshop single licenses and Adobe is making this ridiculously difficult...

  • How do you add a source to the Health app?

    How do you add a source (ie, Nike +) to the new Health app?

    http://help.apple.com/iphone/8/

  • How CAn I Use a URL variable in Flex App

    Let say the link to a web page embedding a flex 2.0 app is
    http://www.myname.com?name=Bruce
    and I need to use the URL.name variable in the Flex app.
    How can I access URL parameters inside my Flex app?
    Bruce

    You probably know by now but I though maybe a could actualy
    answer someone question.
    {Application.application.parameters.name)
    put that in mx:text and you can see the var "name"

  • How do I define javascript global variables to use across windows

    I have a number of web pages. I have javascript for each page. I need to share some data across the web pages. How do I define javascript variables that can be accessed from multiple web pages?

    Use SugarSync.

  • How do I add/remove cities from the Weather app?

    I have a new 3G phone and would like to set new cities for the weather app. It came with Cupertino & NYC. Can someone tell me how to add new cities & delete old ones?

    Launch the Weather app.
    At the bottom right hand corner of the app is a white circle with an i in the middle of it icon.
    Select this icon to remove and add new cities.
    You can also adjust cities up and down on the list.
    When finished, select Done at the top right.

  • How do you add Silverlight to an exiating "Blank App (WIndows Phone)" project?

    I created a new Windows Phone project in VS, and I specified a template of "Blank App (Windows Phone)".
    I then added the following to App.xaml.cs:
    using System.IO.IsolatedStorage;
    I get an error with the squiggly red line underneath "IsolatedStorage" that says:
    The type or namespace named 'IsolatedStorage' does not exist in the namespace 'System.IO' (Are you missing an assembly reference?)
    If I create the project using the "Blank App (Windows Phone Silverlight)" then I do not get the error.
    This makes sense, as IsolatedSTorage is a Silverlight function.
    What I would like to know is how to "add" Silverlight to the first project so that the IsolatedStorage reference is valid.
    I assume I need to add a reference?

    You cannot. You can write a Windows Phone app as either a Silverlight app or a Runtime app, but you cannot add Silverlight to a Runtime app.
    To access app data in a Runtime app (and in a modern Silverlight apps: IsolatedStorage is a legacy API) you can use the Application Data and StorageFile API. See
    Accessing app data with the Windows Runtime and Managing app data for details.

  • How do i add videos to iphone 4 video app

    hey guys you know when you buy a iphone there is an video app that comes along with it right well how
    do i paste videos or put or download videos into that app from my computer
    what format must it be and must i use any converter to do that

    For iTunes content, the iPhone will sync or manually manage that content with but one computer at a time. You need to pick one computer and stick with that computer. Every time you try and sync or manually manage that content with a different computer, all iTunes content will first be erased from your phone and then replaced with the content from the new computer.

  • How can I add http (hotmail) account in Mail app?

    It doesn't give the option for http when you configure the program so I'm just wondering if it's possible to do this.

    http://sourceforge.net/projects/httpmail-plugin
    heres a plugin for mail which lets you access http mail.
    i'm fairly sure it doesnt let you send mail - but i haven't used it and so i'm not sure
    I just happened to post this link in another thread and noticed this one so thought i wouldn't waste a perfectly good clipboard item.

  • How to get the value of the global variable of test stand in labview User interface?

    Hi.
     Can anyone Please share examples and tell me to how access the test stand global variable using labview user interface.
    Solved!
    Go to Solution.

    I'm not surprised that what you are doing doesn't work.  The Start Execution UI Message is triggered when the user clicks a button to start an execution.  Realize that most executions go through a process model.  So you could be looking at the sequence context of the process model and not your client sequence file.
    I recommend reading that link I posted above.  UI Messages are your best bet but you cannot just piggy back on an existing UI Message like this.  They may not be getting sent at the time you need them to be.  The only way to ensure you get what you want is to trigger one yourself at the right time.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

Maybe you are looking for

  • Deleting apps from download queue

    How can I delete a paid app from my download queue? It was not successful as I did not have billing details. I have an app which I bought for $1.99 (I think) on my iPhone. When I wanted to install it on my iPad, I found an app with a same screenshot

  • ITunes requires 64 bit mode.

    I can not access itunes on my macbook pro. Receive a message stating to go to FINDER, GET INFO, and uncheck the 32 bit mode box.  I cannot uncheck the 32bit box - because it is not checked.  How do I acces itunes ?

  • ALV --- Grid/List

    Hi there, I would like to create a checkbox on the ALV list output..I used the option Checkbox when doing the field catalogue ,but the problem is the checkbox is not clickable.. Can u please help on which options must I use to have a clickable checkb

  • App Server stalls every 2-3 deployments of ADF BC - Anyone seen/fixed this?

    Hello, I am running Jdev 10.1.3.2 and the App Server is 10.1.3. We have a separate OC4J container that we have created on the App Server for the ADF BC applications. This is because we were having library conflicts with other non ADF BC applications

  • SCCM installation and post requirements

    I have searched several threads regarding the permission prerequisites for SCCM installation but have not found one that cleary addresses my question. I have setup the appropriate permissions with the SCCM computer accounts and site installation serv