Check client-side login status

I want to know what is the best way to check the login status on the client side. What I'm trying to do is check the login status and if it is not registered in the open popup (login field) using JavaScript.

I can imagine 2 options

  • Make an AJAX call to the server and get the login status.
  • Have a variable on your HTML page and test this variable using JavaScript on the client side. Of course, I do not trust this check, I still have all the necessary checks in my controllers on the server side.

Option 1 is good, but it can add some delay / delay, so it may not be the best option in terms of user convenience. Or am I mistaken, with a good server (I plan to use amazon web services) this delay will be so minimal and the user will not understand it (the question may look silly, but this is my first web development, so please be clear :))

I do not see a problem with option 2, please correct me if I am wrong. As I said, I'm trying to understand best practice.

+5
source share
2 answers

; , ( ), , (AJAX). , , . , , false 5 , .

, : " , false. . BEST PRACTICE , , , , .

...
: -)

+1
0

All Articles