How do I use sessions in PHP and Constrcut's AJAX?

0 favourites
  • 1 posts
  • Hello

    I have a problem with sessions in PHP together with Construct 2.

    I use the following PHP script (credits

    	header('Access-Control-Allow-Origin: *');
            echo "Session variable exists<br/>";
                $_SESSION['test'] = "Success!";
                echo "Variable has been set, refresh the page and see if stored it properly.";
                echo $_SESSION['test'];
            echo "No session variable has been created.";
    When I run this script in my browser it works perfectly:
    [li] First: "Variable has been set"[/li]
    [li] Refresh: "Success!"[/li][/ul]
    But when I create a button in Construct 2 which sends an AJAX request to that session_test.php script the following happens:
    [li] First: "Variable has been set"[/li]
    [li] Refresh: "Variable has been set"[/li][/ul]
    It seems like there's always recreated a new session. I also tried to export my game and to upload it onto my webserver - same result. Does it have something to do with Construct 2?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)