Someone else may correct me but I think you have part of the solution.
I don't think that you need the GUID but I do think you need to have an
ASPX page that houses the SWF.

 

I haven't done much .NET programming except a little in C# and this
might not be the exact way to do it.  

 

So I would create the ASPX page and bring over most of the HTML code
that you have to embed the SWF.  I would wrap the entire RunContent
command and any other places that would embed the SWF with an inline IF
statement.  The IF statement should check if all your session variables
are not null, this is where I am unsure of the exact syntax of the
inline if else statement but should be how you access the session
variables.

 

So I am thinking something like

<% if(Session["VARIABLE_NAME] != null and Session["VARIABLE_NAME_2] !=
null) %>

var accountID = "session=" + <%SESSION["VARIABLE_NAME"]%>;
AC_FL_RunContent( ...
"flashvars", accountID,
...);

<%else%>

Redirect or display and error message

<%end if%>

 

I think the GUID just might be over kill and would create extra DB work
to store, validate and clean up.

 

Let me know if this helps

John

 

************************************************** 

 John R. Piotrowski 

 Programmer Analyst 

 Wharton Computing 

 Email: [EMAIL PROTECTED]

**************************************************

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of thegators_2002
Sent: Tuesday, March 06, 2007 10:03 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Can I access HTTP session variables in Flex
without using Flashvars?

 

Thanks, John, it helped me to ask better questions. The main
application is an ASP.NET app, and there is a link on a page to the
HTML page that is holding my Flex SWF. I was opening the HTML page
with a query string built in the aspx page. 

What I was wondering is if I could put some syntax in the HTML page
like this:

var accountID = "session=" + SESSION.VARIABLE_NAME;
AC_FL_RunContent( ...
"flashvars", accountID,
...);

But I have been told that an HTML page, because it is rendered on the
client, cannot access session variables, which are on the server.

Someone here suggested I use an aspx page instead, have it create a
GUID, inject it in the html sent to the client, and then send that
guid to the web service, which can access the session, validate the
guid, and then clear that variable and return my data to my SWF. Does
that sound logical? Or is there an easier way I am overlooking? I
understand, now, the security hole accessing session variables from
the client would present, so maybe that's why it can't be done from
inside the Flash movie?

Thanks, again,
Pete

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Piotrowski, John" <[EMAIL PROTECTED]> wrote:
>
> The short answer is Yes you can use session variables instead or url
> variables. It depends on what scripting language you are using. For
> example, I use coldfusion and can pass url variables through FlashVars
> by accessing the variables using URL.VARIABL_NAME. I can easily
replace
> this syntax to use a session variable by setting the flashvars to
> SESSION.VARIABLE_NAME. In .NET with C# I think you access the session
> variables by SESSION["VARIABLE_NAME"].
> 
> 
> 
> Does this help?
> 
> 
> 
> John
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of thegators_2002
> Sent: Monday, March 05, 2007 6:32 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Can I access HTTP session variables in Flex
> without using Flashvars?
> 
> 
> 
> I am able to create a web service request in Flex, using parameters
> sent to the html page via a query string which is then passed in using
> flashvars. However, now I am being asked if I can do this without
> having a query string for all to see with this information in plain
> sight. The idea is to use session variables to store this info. It's
> just a few items, like an account ID, user ID, a URL for the WSDL
> file, and a couple others.
> 
> I am not familiar with web sessions or with how that info gets
> accessed by Flex, I am more of a desktop developer. So I ask if this
> is a sound strategy, or if there are other, better ways to do this? 
> And if there are any good examples available? 
> 
> The app has users log in and get authenticated, and we want to pass
> that info to the web service. As it is right now, not authenticating
> the user request and passing a couple IDs and a URL in the query
> string would allow anybody anywhere to access that web service at any
> time. I need some way to secure it or at least drastically limit the
> amount of time it would be valid.
> 
> Thank you for any assistance!
> 
> Here is my code as of right now:
> 
> private var accountID:String; 
> private var systemUserID:String;
> private var myWebServiceURL:String;
> 
> public var MyService:WebService = new mx.rpc.soap.WebService();
> 
> // This method runs on start-up. It pulls in Flashvars from the
> parent HTML file, and starts up the web service.
> public function initApp():void
> { 
> accountID = Application.application.parameters.accountID;
> systemUserID = Application.application.parameters.systemUserID; 
> myWebServiceURL = Application.application.parameters.webServiceURL;
> 
> // Call the web service to get an RRM results doc
> UseWebService( myWebServiceURL + "?WSDL");
> }
> 
> // Create a web service and load the WSDL, using ActionScript
> public function UseWebService( wsdl:String):void 
> {
> // Set the path to the WSDL
> MyService.wsdl = wsdl; 
> 
> // Set listeners for the result and fault events of the specific web
> service method 
> 
>
MyService.GetRRMAnalysisResultsFromAccountIDStr.addEventListener("result
> ",
> resultHandler);
> 
>
MyService.GetRRMAnalysisResultsFromAccountIDStr.addEventListener("fault"
> ,
> faultHandler); 
> 
> // Add a listener event for the web service load completion
> MyService.addEventListener("load", loadHandler);
> 
> // Load the WSDL into the web service
> MyService.loadWSDL();
> }
> 
> // Once the WSDL is loaded into the web service, this handler will
> run. Call the appropriate service and send credentials.
> public function loadHandler(event:LoadEvent):void 
> {
> MyService.GetRRMAnalysisResultsFromAccountIDStr( accountID,
> systemUserID);
> }
> 
> 
> // If there is a fault in setting up the web service, this will run. 
> It informs the user there was a problem.
> public function faultHandler(event:FaultEvent):void 
> {
> Alert.show("An error occurred while accessing the web service: " +
> event.fault.faultString + ".\nPlease close this application.",
"Error");
> } 
> 
> // Event Handler: listens for the web service call to be completed 
> private function resultHandler(event:ResultEvent):void 
> { 
> // Create an XML doc and load it with the XML string returned from the
> web service
> var myXml:XML = new
> XML(MyService.GetRRMAnalysisResultsFromAccountIDStr.lastResult);
> 
> // Copy the XML doc to the custom class which will handle extracting 
> ResultSet.XmlResults( myXml);
> }
>

 

Reply via email to