ochi Posted January 21, 2010 Share Posted January 21, 2010 Hi everybody! I posted yesterday about login/logout, and I was sure it worked, but today I found a new mistake :'(. The problem is when I logout, I login again, but I press "cancel" button, then as the previous USER and PASSWORD were correct, it allow me enter, but if I do it twice it works as I want. There is my code: <?php function check4login() { session_start(); if (isset($_SESSION['login'])) { if (is_authorized($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])) { $_SESSION['user'] = $_SERVER['PHP_AUTH_USER']; unset($_SESSION['login']); return true; } } $_SESSION['login'] = true; header("WWW-Authenticate: Basic realm=\"User and password\""); header("HTTP/1.0 401 Unauthorized"); } function is_authorized($usuario,$contrasena) { if ($usuario == 'user' && $contrasena == 'pass') { return true; } else { return false; } } check4login(); ?> Link to comment https://forums.phpfreaks.com/topic/189285-loginlogout-again/ Share on other sites More sharing options...
ochi Posted January 21, 2010 Author Share Posted January 21, 2010 Ok! I found it, it was a mistake in the rest of my code, this part was perfect!!! Thank you anyway. Regars Link to comment https://forums.phpfreaks.com/topic/189285-loginlogout-again/#findComment-999263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.