I've been scouring the net for days and still no luck solving this problem. The amfphp counter example doesn't even work (on either my local server or external hosting) so I'm starting to wonder where the problem lies.
To clarify: I can send and return vars to and from AMFPHP, so the services are working, but I just can't get the sessions to stick.
The deal is this: I can set and get sessions with straight PHP files, so long as I put a session_start() up the top before either setting or reading the session var. That's fine.
The problem arises when I try to do the above via AMFPHP. I've created a service with 2 functions - write() and read(). In the write function, I set the session var, in the read function I return it to amfphp. I can access the session var after setting it (in the write function it still contains the string) but as soon as I try to access it with a second call from AMFPHP the session var appears to contain nothing.
I've tried putting the session_start() outside the class, inside the class, everywhich way to no effect.
If anyone can steer me in the right direction on this it would be much appreciated.
Code:
<?php
session_start();
class TestExchange
{
function TestExchange(){
}
function write($in)
{
$_SESSION['sessvar'] = $in;
return "setting session to " . $_SESSION['sessvar'];
}
function read()
{
return "returning session: " . $_SESSION['sessvar'];
}
}
?>
Here is the AS3 code if that helps, although I believe the problem lies at the PHP end.
Code:
var gw:NetConnection = new NetConnection();
gw.connect("http://localhost:8888/amfphp/gateway.php");
var res:Responder = new Responder(onResult, onFault);
function onResult(responds:Object):void {
trace(responds);
for (var i in responds) {
trace (responds[i]);
}
}
function onFault(responds:Object):void {
for (var i in responds) {
trace (responds[i]);
}
}
//set session var
gw.call("TestExchange.write", res, "test");
//retrieve session var
butt.addEventListener(MouseEvent.CLICK, onClicker);
function onClicker(e:MouseEvent):void {
gw.call("TestExchange.read", res);
}
Bookmarks