Sending login details from website to the game?

0 favourites
  • 5 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • Hi,

    I need a way to send the player's username & password from my website to the game after they login.

    Right now the player's have to login on each game, but it would be more easy to login once on the website and have access to all the games without having to login again.

    I was thinking sending the login details as a variable through the browser but not sure how to do that and I don't think it would be that secure either.

    If anyone has any ideas I would greatly appreciate it.

    Have a great day!

    Regards,

    Edgar

  • I need a way to send the player's username & password from my website to the game after they login.

    What you are looking for is an authentication token. Your question isn't actually all that different from mine, actually: construct.net/en/forum/construct-3/how-do-i-8/user-authentication-custom-157301

    If you log in and store the token on the website, it should be accessible as a cookie, assuming the game's page is also within that same website; you can use JavaScript to grab it most likely, then just store it as a global variable.

    And just to also drive this point home too...

    User authentication is an extremely tricky subject, though I agree that using cookies and session data within Construct 3 is not easy because no tools are provided to do so without the use of Javascript.

  • Thanks for your reply.

    I tried doing this with Javascript and are able to store the username in a cookie on the website, but I'm not sure how to do the script in Construct, tried a couple of different ways.

    Do you have any script examples or been able to get a variable a into Construct and store it as a global variable yourself?

    Thanks.

    Regards,

    Edgar

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My model has the game all under Construct with the back end being mostly JSON APIs and sockets, so I haven't needed to do this, nor have I tried, but it's probably possible; I just don't know how off the top of my head. If I find something out I'll post it here.

  • ...oh, small bump by the way: I should mention that any code attempting to grab a cookie being ran in preview won't actually work - you'd need to deploy it to the site itself in order to test it. Otherwise, there's no cookie to grab, because the preview is running on Construct's website and not your own.

    I suppose for testing purposes you could try implementing the login form within construct and store the token as a cookie or in session data, then try to grab it using a different script, but you'd need to configure CORS on your webserver for that to be possible.

    It's tricky, and I'm sure what we're doing here was never intended by the developers of construct; this wouldn't work at all on a mobile deployment, only HTML5.

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