-4

I have a logout.php file that is a work around to simulate logging out of basic authentication by passing false credentials.

    <?php
    session_start();
    header('WWW-Authenticate: Basic realm="File Upload"');

    $(function() { $("WWW-Authenticate").submit(); });

    header('Location: http://www.homepage.com') 
    session_write_close();
    ?>

This does not work, but is what i have so far. My link takes me to this code and I want it to call the basic auth dialoge like this:

enter image description here

After this appears I simply want something to automatically hit enter to simulate the clicking of the OK button and then I want to redirect back to my homepage.

j08691
  • 204,283
  • 31
  • 260
  • 272
CPM
  • 51
  • 2
  • 5
  • 3
    You can't mix PHP and jQuery like that... – Mike Aug 06 '13 at 18:17
  • I now realize that, so there is no code from any language that I can force a client/browser to run and enact the basic auth dialogue? – CPM Aug 06 '13 at 20:04
  • See this question: http://stackoverflow.com/questions/449788/http-authentication-logout-via-php – Mike Aug 06 '13 at 20:07

2 Answers2

3

You won't be able to make this popup to be modified by Javascript or JQuery. You have this popup because you are writing with PHP to the agent to ask for credential. Once filled up by the user, the data is sent back to the server (PHP). Javascript/JQuery doesn't have anything to do with this.

Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
  • I perfectly understand that this is asking a client/user to fill in information. What I was trying to do is create a workaround to the age old problem of unable to truly logout of http basic auth. I found this possible solution on one of stacks other posts as a potential workaround and was attempting to execute it. – CPM Aug 06 '13 at 19:18
0

You seem to have mixed up what's javascript and what's PHP. Within the generally php is executed on the serverside. "$(function ... " looks like javascript (jQuery to be specific) and should be in a tag or in a js file, and will be executed client side.

Alexander Olsson
  • 1,908
  • 1
  • 15
  • 24