I have a login system in my website if i use the url without www and login it is normal but when i change the url of my website by adding www to it the website will show my account as logout. and if i change the url again by removing www it will show my account as login (without login again) my login function is :
$username = $_POST['username'];
$password = md5($_POST['password']);
$users = $GLOBALS['db']->query("SELECT * FROM users WHERE username='$username' AND password='$password'") or $GLOBALS['db']->raise_error(); // Leaving 'raise_error()' blank will create an error message with the SQL
$users_number = $GLOBALS['db']->num_rows($users);
if(!empty($users_number))
{
while($users_sql = $GLOBALS['db']->fetch_array($users))
{
$_SESSION['username'] = $username;
$_SESSION['id'] = $users_sql['id'];
$_SESSION['logged_in'] = 'true';
header('Location:./');
}
}
else
{
$error_msg = "Worng combination";
header('Location:?page=login.php&login_error_msg='.$error_msg);
}
I want to know is there any change that i should make to make the www.example.com and example.com see the same login credentials