microl44 / Julet

Website visualizing data from my watched movies, brought forward by the jul.
3 stars 1 forks source link

Login functionality should use a token-based system #74

Open microl44 opened 1 year ago

microl44 commented 1 year ago

For the sake of security, scalability and flexibility, the website shouldn't save user-information in the $_SESSION variable and instead should use a token-based approach. This includes creating a new table in the database for said token.

Steps the system should take:

  1. The user submits his/her information in a login form.
  2. On successful login, the server generates an unique token and is stored in a "token" table in the database.
  3. The token is sent back to the user and stored in $_COOKIE using setcookie function.
  4. When the server loads a page, use the $_SERVER['HTTP_AUTHORIZATION'] to check if token exists
  5. If token exists, use DB query to check if token exists in DB and if it's expired or not.