Session cookie to play sound with Java Script just once

Viewed 58

I encrypted a directory that contains several folders by directories Admin (Protect Option), for example,memberarea directory.

now if someone opens a page of these directories , he must enter his username and password so that he can see the contents of that directory.

I used the following code to write a welcome text to display the text related to each user. In addition, according to the entered username, an audio file will be played when the page open:

        <?php
        $user_name = $_SERVER['PHP_AUTH_USER'];
            if ($user_name == "admin") {
                $name = "Sir Alex Morgan";
                echo '<div class="wellcome_message">' . $name . ' ، welcome to your site :)</div>';
                echo '<script type="text/javascript">
                        window.onload=function(){
                            document.getElementById("admin_audio").play();
                        }
                        </script>';
            }
            elseif ($user_name == "user1") {
                $name = "Miss Mary";
                echo '<div class="wellcome_message">' . $name . ' ، nice to meet you</div>';
                echo '<script type="text/javascript">
                        window.onload=function(){
                        document.getElementById("user1_audio").play();
                        }
                    </script>';
            }
            .
            .
            .
            ?>

Now I want to make the above process happen only once in each browser session, ie if the user, for example, went from page domain.com/memberarea/part1/index.php to page domain.com/memberarea/part3/page.php just as he does not need to enter the password again until the browser is closed, The welcome message and voice will only be displayed for the first time.

0 Answers
Related