-1

I'm just getting into SPAs with PHP and AJAX, and from the W3 Example:

xmlhttp.open("GET", "gethint.php?q=" + str, true);
xmlhttp.send();

You can access the PHP directly at https://www.w3schools.com/php/gethint.php?q=an

I want my website to function similarly in regard to SPA, but I want to ensure that the user is logged in and a 'premium' member to be able to access the URL. Is there something I can do with SESSION or something among those lines?

Reed
  • 1,515
  • 1
  • 21
  • 38
  • Wow, this question is all over the place. Of course you can use sessions to store and maintain user information, though I am not sure what your code example has to do with things. – Jay Blanchard Sep 11 '17 at 18:00
  • Sorry, new to PHP and AJAX. I guess I don't know how to ask my question then. – Reed Sep 11 '17 at 18:02
  • All you're really doing is RESTful authentication. Here's 2 links to get started: https://stackoverflow.com/questions/20963273/spa-best-practices-for-authentication-and-session-management & https://stackoverflow.com/questions/319530/restful-authentication – waterloomatt Sep 11 '17 at 18:13
  • @waterloomatt thanks for the links, that's just what I was looking for! Feel free to post as an answer I can select as best. – Reed Sep 11 '17 at 18:20

1 Answers1

1

You're implementing RESTful authentication which is covered in these 2 topics.

  1. RESTful Authentication
  2. SPA best practices for authentication and session management
waterloomatt
  • 3,662
  • 1
  • 19
  • 25