PHP Sessions and C3

0 favourites
  • 8 posts
From the Asset Store
Paypal PHP Supports multiple platforms, Web/html5 Android, IOS. (Including storing transaction data)
  • Hello,

    Seems I am unable to maintain a php SESSION when using Ajax and C3. I verified my php code works with a regular browser.

    But when I'm using C3, the SESSION seems to reset at every AJAX request.

    Is this impossible with C3 or am I doing something wrong? I do have my CORS access setup correctly as well.

  • Btw I just want to add I was having the same issue wich made me give up!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's because of cross domain.

    If you put your construct app on the same server as the php page with the script fetching session_id, the ID remains the same.

    If you use the preview function, it becomes cross domain and each request will end up being a new session.

  • I'd add that there's nothing Construct-specific about the network requests. When you use AJAX, the browser makes network requests the same way as any other page. However if you are making a cross-domain request that may have various implications, but those are all the same as if you were making cross-domain requests with any other web pages.

  • Thanks all, once I exported to HTML5 and hosted on the same site it works as expected. This really makes things tricky for quick testing though!

    Is there any way to get this working with cross domain?

  • From a construct perspective, no.

    There are options to get it working, but you'll have to resort to storing an existing session in a database on the php side, and in the CS3 app, and later use the stored ID from CS3 to contact the database, and see if it exists, and has extra session variables stored.

    Not the most ideal solution.

    I have similar problems testing a multiplayer setup :\ need to export and upload to have any sense of rapid testing effect.

    Ashley can we get an option to export HTML version to a FTP location ?

  • Hmm, would storing the session ID locally really be that bad security wise? This will all be in app so URLs wont be visible to the user.

  • Hmm, would storing the session ID locally really be that bad security wise? This will all be in app so URLs wont be visible to the user.

    Security is a fickle thing, over time I have come to look at it with : "What's there to steal, or take"

    If you have a simple game with no payment or purchase options, then, what's the worst they could do with the information ?

    Personally, if I were to retrieve information from a database, I wouldn't even use the session ID, and simply create a log in system over PHP and Ajax. This also isn't as secure as I'd like, but it's more standard, and gives me more options to somewhat secure my information.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)