1

A good example of this is facebook's mobile view. This is not reliant on javascript and is able to authenticate the user with the server. If they are authenticated it will request and load your custom webpage, and if not you will see facebook's default home page.

How is all this accomplished without javascript and before the page renders? Is it PHP that runs before the DOM is rendered or is it another technology?

Adam Griffiths
  • 680
  • 6
  • 26
  • 60
  • Facebook has used PHP in the past (https://github.com/facebook/hhvm/wiki), but I think now they are moving towards utilising a Javascript backend – James Paterson Apr 16 '16 at 16:28
  • I understand they are moving away from php but telling me what the backend is doesn't actually tell me how the front end (i.e. the browser) can authenticate the user before the page is loaded without javascript or php – Adam Griffiths Apr 16 '16 at 16:32
  • not sure what the above comment has to do with this question – omarjmh Apr 16 '16 at 16:32
  • Users have cookies that can be used to authenticate them, as they are sent with the page request. PHP can read these cookies and determine whether a user is valid before sending a response. – James Paterson Apr 16 '16 at 16:34

1 Answers1

1

FB uses cookies to handle this. Before the page renders the cookie is sent to the server with the initial page load request, if the cookie is still valid you get past the login page, otherwise you need to login again.

Here is how you can see what cookies you have in chrome:

  • In the top right, click the Menu Chrome menu. Click Settings > Show advanced settings.
  • In the "Privacy" section, click Content settings.
  • Under "Cookies," click All cookies and site data.
  • To delete all cookies, click Remove all.
  • To delete a specific cookie, hover over a site, then click the that appears to the right.
  • You can also choose to remove all cookies created during a specific time period.

https://support.google.com/chrome/answer/95647?hl=en

omarjmh
  • 13,632
  • 6
  • 34
  • 42