AmAuron Posted July 26, 2015 Share Posted July 26, 2015 Hi there,Sorry if this question seems simple, but i searched the forum and didn't find any specific topics related to this issue. I'm doing a game that uses the user login on a page as an identifier to record and save his score. My question is, imagining we are using a server,the user makes the login and after that is redirected to the game, is there any way to do an HTTP get or a function the get extra information that we arepassing when we are redirecting to the game? The only thing i need is when we are redirecting, the game recieves the username. Thank you for your patience and answers. Link to comment Share on other sites More sharing options...
Langerz82 Posted July 26, 2015 Share Posted July 26, 2015 Sure is, look at:http://papermashup.com/read-url-get-variables-withjavascript/ Tilde and AmAuron 2 Link to comment Share on other sites More sharing options...
AmAuron Posted July 26, 2015 Author Share Posted July 26, 2015 Sure is, look at:http://papermashup.com/read-url-get-variables-withjavascript/Thank you for this...one more question if you may....where should i put this like into code on the game so that i get the variable on the start of the game? Link to comment Share on other sites More sharing options...
tips4design Posted July 26, 2015 Share Posted July 26, 2015 Thank you for this...one more question if you may....where should i put this like into code on the game so that i get the variable on the start of the game? You could put it in the preload function of your main game state. Link to comment Share on other sites More sharing options...
AmAuron Posted July 26, 2015 Author Share Posted July 26, 2015 You could put it in the preload function of your main game state.Okay but i got several states in this order....Boot State -> Preloader State -> Main Menu State ->goes to several states from here I think you mean to put that on the Boot State right? The Boot state is the first state that runs and i use him to load the sprite of the preloader bar and logo of the game. Link to comment Share on other sites More sharing options...
tips4design Posted July 26, 2015 Share Posted July 26, 2015 Okay but i got several states in this order....Boot State -> Preloader State -> Main Menu State ->goes to several states from here I think you mean to put that on the Boot State right? The Boot state is the first state that runs and i use him to load the sprite of the preloader bar and logo of the game. It doesn't really matter as long as you load the username before you need it. If you want it to persists through multiple states you can either bind it as an attribute of the game object, or simply make it a global variable. AmAuron 1 Link to comment Share on other sites More sharing options...
AmAuron Posted July 26, 2015 Author Share Posted July 26, 2015 It doesn't really matter as long as you load the username before you need it. If you want it to persists through multiple states you can either bind it as an attribute of the game object, or simply make it a global variable.Ty for the help i will test it out now ! I will give feedback soon Link to comment Share on other sites More sharing options...
AmAuron Posted July 26, 2015 Author Share Posted July 26, 2015 IT worked guys [email protected] Is there anyway to make this a little safer?like everyone can see their id :X Link to comment Share on other sites More sharing options...
tips4design Posted July 26, 2015 Share Posted July 26, 2015 IT worked guys [email protected] Is there anyway to make this a little safer?like everyone can see their id :XSet the username in a cookie on server side and then read the cookie on the client, instead of reading from the URL. AmAuron 1 Link to comment Share on other sites More sharing options...
AmAuron Posted July 26, 2015 Author Share Posted July 26, 2015 Thank you very much Link to comment Share on other sites More sharing options...
Recommended Posts