PHP Session Destroy on Log Out Button

前端 未结 3 763
感动是毒
感动是毒 2020-12-30 08:21

I\'m currently working on a site that has a log-in (username and password) - The password protection is done by the operating system within the web server at folder level ca

3条回答
  •  甜味超标
    2020-12-30 08:33

    The folder being password protected has nothing to do with PHP!

    The method being used is called "Basic Authentication". There are no cross-browser ways to "logout" from it, except to ask the user to close and then open their browser...

    Here's how you you could do it in PHP instead (fully remove your Apache basic auth in .htaccess or wherever it is first):

    login.php:

    
    
        
    Username:
    Password:

    index.php

    
    
        

    here is my super-secret content

    Click here to log out Click here to log in.'; }

    logout.php:

    Go back';
    

    Obviously this is a very basic implementation. You'd expect the usernames and passwords to be in a database, not as a hardcoded comparison. I'm just trying to give you an idea of how to do the session thing.

    Hope this helps you understand what's going on.

提交回复
热议问题