5

Is there a way to trigger the native browser login prompt UI (using PHP or jQuery) but to use the values that the user enters into the prompt before the browser tries to authenticate using its own methods?

enter image description here

The only things I have found in relation to this are some answers concerning ASP and Java.

Failing this, is there a 'standard' jQuery UI I can use? Similar to the 'standard' datetime jQuery UI for example?

myol
  • 8,857
  • 19
  • 82
  • 143
  • 1
    please explain what the native browser login ui is? – Grumpy Dec 23 '15 at 11:09
  • windows chrome (or firefox?) prompt attached – myol Dec 23 '15 at 11:15
  • Possibly helpful: http://stackoverflow.com/questions/491914/pure-javascript-code-for-http-basic-authentication – Gerald Schneider Dec 23 '15 at 11:22
  • What does "before the browser tries to authenticate using its own methods" mean? Just send the authentication headers to show the prompt and handle the values using `$_SERVER['PHP_AUTH_USER']` and `$_SERVER['PHP_AUTH_PW']`. – PeeHaa Dec 23 '15 at 11:27
  • @PeeHaa - I guess that's what I'm asking; what are the 'authentication headers' I need to send (to where) to display the prompt? – myol Dec 23 '15 at 11:33
  • 1
    I would say the manual is a good resource http://php.net/manual/en/features.http-auth.php. – PeeHaa Dec 23 '15 at 11:39
  • Thanks, never would have found it buried in there – myol Dec 23 '15 at 11:42

2 Answers2

7

What you're looking for is called HTTP Authentication. It takes place on the server, so you should use PHP in your case.

See examples at http://php.net/manual/en/features.http-auth.php

Luke
  • 1,369
  • 1
  • 13
  • 37
0

For others stumbling across this it seems the native browser prompt is intrinsically tied into authenticating a user for the entire time the browser is open or until they log out.

If you want a way to use the native browser prompt UI while implementing your own authentication logic (i.e. have the prompt appear multiple times in a single browsing session without logging a user out - like password action prompts) it seems this cannot be done.

I had to create a stylized jQuery prompt in my case (html would work too). It is consistent across browsers but obviously not native to any browser.

myol
  • 8,857
  • 19
  • 82
  • 143