How an authentication validation works with Angular + PHP

Asked

Viewed 144 times

2

I am beginner in angular (version above 2) I am studying the communication of angular with PHP, in the httpClient part (of rxjs) to make the GET, POST, PUT and DELETE understood well. My question is how does it work to log in? From what I understand so far it’s like this:

I have a form sending the login and password via POST with angular, ai in PHP I validate it in Mysql and if the login and password are right I will enter a token in PHP, store this token in a PHP Session and send it to store also in the browser Storage Session, then I always keep comparing the token of the Session Storage with the token there of the PHP Session and so I know if the usr is already logged in.

How would it work? I would like to understand this part better.

  • Yes, that’s basically it, there are already libraries that work with various error data processing and token comparisons, one of them is the JWT token, from a look https://dev.to/robdwaller/how-to-create-a-json-web-tokenusing-php-3gml

  • Thanks for the help, just be sure to talk a lot about not using Session on the server side when working with tokens. The other ways to store tokens (server side), besides Sesssions, would be: store in database or save in txt files. I think storing in Sesssion the memory consumption is higher, wouldn’t it be better to temporarily save in a database or txt file? Is there any way to validate the token without storing it somewhere, for example: a generic function capable of validating each user’s keys as a whole and not just Signature?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.