PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
islan wrote:I'm having a problem where I login to my page with a user, then logout, and when I login with a different user, it still logs me in as the first one.
OK, first things first. You do not need session_start() when you are going to use session_destroy() right after it. Only use session_start() if you plan to use $_SESSION.
Secondly, you do not need to use unset() if you are going to using session_destory().
Lastly, make sure you are actually visiting the pages in the following order:
spider.nick wrote:OK, first things first. You do not need session_start() when you are going to use session_destroy() right after it. Only use session_start() if you plan to use $_SESSION.
Secondly, you do not need to use unset() if you are going to using session_destory().
Lastly, make sure you are actually visiting the pages in the following order:
HTML: login page
PHP: process login page
PHP: successful login page
PHP: logout page
Repeat 1 - 4
Nick
Okay, I commented out session_start() in logout.php, and unset in checklogin.php (the first one). It doesn't seem to have changed another, as the first user's name is popping up. I suppose it might be important for me to show the code that returns the name as well:
islan wrote:Okay, I commented out session_start() in logout.php, and unset in checklogin.php (the first one). It doesn't seem to have changed another, as the first user's name is popping up. I suppose it might be important for me to show the code that returns the name as well:
SELECT firstname, lastname FROM ClientInfo WHERE<username_of_logged_in>
Where <username_of_logged_in> is the value of $_SESSION['username']. The above query, will always return true, and will always pull the first record from the table.