--------web.xml文件
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
--------Java代码
public class GetSeesion {
/**
* 设置session
* */
public void setSession(String name,String value){
FlexContext.getFlexSession().setAttribute(name, value);
}
//获得session
public String getSession(String name){
String userid=(String) FlexContext.getFlexSession().getAttribute(name);
return userid;
}
}
----------在remoting-config.xml中加入
<!-- 用户信息保存到session中 -->
<destination id="sessionBiz">
<properties>
<source>com.ssfx.util.GetSeesion</source>
<scope>application</scope>
</properties>
</destination>
-------使用session
<mx:RemoteObject id="sBiz" destination="sessionBiz" showBusyCursor="true">
<mx:method name="setSession"/>
<mx:method name="getSession" result="sessionHandle(event)"/>
</mx:RemoteObject>
<script>
<![CDATA[
sBiz.setSession("userId",txtUserId.text);
sBiz.getSession("userId");
/* 获得后台session处理函数 */
private function sessionHandle(event:ResultEvent):void{
var userCode=String(event.result);
this.addPlanMess(userCode);
}
]]>
</script>