Professional Web Applications Themes

PHP and .HTACCESS - PHP Development

I am new to learning PHP and have learned a lot over the last few weeks. One thing that I can not find anywhere is how to code it so a user can click logoff and have it route them to another page and remove their authentication that was set. ie... I user goes to www.mysite.com and clicks on a link called STAFF The STAFF.mysite.com is protected with authentication using .htaccess The staff enters their ID and Password and is allowed in. I want to have a button that says LOGOFFF that will remove the authentication I know how to ...

  1. #1

    Default PHP and .HTACCESS


    I am new to learning PHP and have learned a lot over the last few weeks. One
    thing that I can not find anywhere is how to code it so a user can click logoff
    and have it route them to another page and remove their authentication that was
    set.

    ie... I user goes to www.mysite.com and clicks on a link called STAFF
    The STAFF.mysite.com is protected with authentication using .htaccess
    The staff enters their ID and Password and is allowed in.
    I want to have a button that says LOGOFFF that will remove the authentication
    I know how to do the header(location... to route them back to another page, but
    I have not been able to remove the authentication so it will ask them for their
    password again when they return to staff.mysite.com

    I have even tried:

    header('WWW-Authenticate: Negotiate');
    header('WWW-Authenticate: NTLM', FALSE);

    but no go...

    Thanks in advance!!

    Jim
    James Guest

  2. #2

    Default Re: [PHP] PHP and .HTACCESS

    --- "James D. Stallings" <net> wrote: 

    HTTP authentication is not a very good tool for implementing sophisticated
    access control. Though it is possible to simulate a log out, it is not very
    straightforward (some would call it a hack), because there is no mechanism for
    the server to instruct the browser to forget the authentication credentials.

    So, I recommend using PHP sessions instead.

    However, if you really want/need to use HTTP authentication, you can read this
    page to get some other users' suggestions:

    http://www.php.net/features.http-auth

    Hope that helps.

    Chris

    =====
    My Blog
    http://shiflett.org/
    HTTP Developer's Handbook
    http://httphandbook.org/
    RAMP Training Courses
    http://www.nyphp.org/ramp
    Chris Guest

  3. #3

    Default Re: [PHP] PHP and .HTACCESS

    it is virtualy impossible to make the browser forget the credentials.

    How this is solved is that the logoff link is
    login.php?logoff=username

    In login.php you check for $_GET['logoff'] variable, if it is set you
    will not let the user with the same name ($_GET['logoff']) log in.

    James D. Stallings wrote:
     
    Marek Guest

  4. #4

    Default str_word_count Broken?

    I ran into a strange problem this morning. Suddenly I am getting an
    error that str_word_count is undefined, even though it has been working
    for the past few months. Anyone know why this may be? Nothing in the my
    code has changed at all.

    I did phpinfo() to check the server and it is running 4.2.2. I have a
    workaround for the time being, but it is very strange.

    Steven J. Walker
    Walker Effects
    www.walkereffects.com
    com
    Steven Guest

  5. #5

    Default Re: [PHP] str_word_count Broken?

    str_word_count is available since version 4.3. Check your setup, someone
    restarted webserver with wrong config directory specified.

    Steven Walker wrote: 
    Marek Guest

  6. #6

    Default Printer Functions

    Hello,

    I was wondering if anyone has had any level of success with printer
    functions.

    I'm trying to get the following code to work:

    <?php
    $handle = printer_open();
    printer_start_doc($handle, "Hello World");
    printer_start_page($handle);
    printer_end_page($handle);
    printer_end_doc($handle);
    printer_close($handle);
    ?>

    I get the following error: "printer_open() is an undefined function".
    I'm guessing that the printer functions were never installed with my
    version of PHP?.?.?.? I'm currently running PHP Version 4.3.3

    Thanks,
    Roger
    Roger Guest

  7. #7

    Default Re: [PHP] Printer Functions

    Check the manual. It's windows only extension, you must have
    php_printer.dll in your extension directory and
    extension=php_printer.dll must be in php.ini


    Roger Spears wrote: 
    Marek Guest

  8. #8

    Default Re: [PHP] Printer Functions

    php.net/printer:

    "These functions are only available under Windows 9.x, ME, NT4 and 2000. They
    have been added in PHP 4.0.4.

    Installation

    Add the line extension=php_printer.dll to your php.ini file."





    On Friday 03 October 2003 02:15 pm, Roger Spears wrote: 

    --
    Evan Nemerson
    com
    Evan Guest

  9. #9

    Default Re: [PHP] PHP and .HTACCESS

    If I've got my basics right, the auth user and pass will be sent by the
    browser. You will need a way to tell the browser not to send the user and
    pass anymore.

    - Sid

    ----- Original Message -----
    From: "James D. Stallings" <net>
    To: <php.net>
    Sent: 3 October 2003 Friday 9:04 AM
    Subject: [PHP] PHP and .HTACCESS

     
    One 
    logoff 
    that was 
    authentication 
    page, but 
    their 
    Sid Guest

  10. #10

    Default Re: [PHP] PHP and .HTACCESS

    On Fri, 3 Oct 2003, Marek Kilimajer wrote:
     [/ref]
     

    It can be done in few ways, but IIRC none of them
    is guaranteed to work with _every_ browser. Simplest one
    is to use a new IE6 (SP1) feature by calling javascript:
    -cut-
    <a href="#" onclick="
    doent.execCommand('ClearAuthenticationCache');
    alert('You have been logged out!');
    ">Logout</a>
    -cut-

    This of course is quite useless sinse it only works with
    IE6.

    A second way would be to overwrite the cached credentials with
    fake ones. For that you would need to do another .htaccess
    protected directory. Lets call it /logout/. You create the
    .htaccess and .htpasswd file. Create user 'fake' with
    password 'fake' (only for this directory).

    Then you would create a logout link with:

    -cut-
    <a href="http://fake:example.com/logout/">Logout</a>
    -cut-

    This should overwrite the credentials with most browser, but
    again is not guaranteed to work with every browser.

    --
    Mika Tuupola http://www.appelsiini.net/~tuupola/
    Mika Guest

  11. #11

    Default Re: [PHP] PHP and .HTACCESS

    * Thus wrote Marek Kilimajer (sk): 

    You sorta of can. If you redirect the user to something like:

    http://username:badpasswordhost/path/

    The browser will/should forget the credentials.


    Curt
    --
    List Stats: http://zirzow.dyndns.org/html/mlists/php_general/

    "I used to think I was indecisive, but now I'm not so sure."
    Curt Guest

Similar Threads

  1. htaccess and Contribute
    By jenijoss in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: June 18th, 12:22 AM
  2. htaccess
    By jenijoss in forum Macromedia Contribute Connection Administrtion
    Replies: 0
    Last Post: June 15th, 01:28 AM
  3. mod_rewrite in .htaccess
    By Jint in forum PHP Development
    Replies: 3
    Last Post: August 15th, 07:15 PM
  4. php .htaccess
    By RG in forum PHP Development
    Replies: 3
    Last Post: September 23rd, 01:59 PM
  5. [PHP] htaccess?
    By Dean E. Weimer in forum PHP Development
    Replies: 0
    Last Post: July 11th, 05:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139