doude4201 2011-07-03 22:02
浏览 48
已采纳

通过Flash发送POST,显示没有登录PHP?

So here's the deal,

I'm trying to save variables from flash to PHP, however when i try to do so the php script seems to not acknowledge that i'm logged in.

This would mean that the session doesn't arrive in flash. How do i fix this?

AS3 added:

var bitmap:BitmapData = new BitmapData(loaded_swf.width, loaded_swf.height - 273, false, 0x000000);

var saveSelfyRequest:URLRequest = new URLRequest('urlhere.php');

saveSelfyRequest.contentType = "application/octet-stream";
saveSelfyRequest.method = URLRequestMethod.POST;

var bytes:ByteArray = PNGEncoder.encode(bitmap);

requestLoader = new URLLoader();

saveSelfyRequest.data = bytes;

requestLoader.load(saveSelfyRequest);
requestLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
  • 写回答

1条回答 默认 最新

  • dousi6192 2011-07-03 23:35
    关注

    I don't know Flash or ActionScript, but once I had a similar problem while developing a Java Applet which interacts with a php application which requires login. The problem was the fact that the applet make independent requests to the web app and not through the browser, so it was not passing a proper session id to the php app.

    I solved this problem by passing a session_id parameter to the applet (using a param tag) and then making post requests to the app by setting a cookie with the value PHPSESSID=xxxxx in the HttpClient used for the request.

    Maybe you can try the same inside ActionScript.

    To get confirms on my theory you can print all received headers in the php application to see if the cookie header is sent in the request.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。