What are some potential pitfalls to avoid when implementing a login system in PHP, especially in terms of user authentication and data security?

Issue: Storing plain text passwords in the database can lead to security vulnerabilities if the database is compromised. It is crucial to hash passwords before storing them to enhance data security.

// Hashing the password before storing it in the database
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
```

Issue: Using unsalted hashes for password storage can make it easier for attackers to crack passwords using precomputed rainbow tables. Salting passwords before hashing adds an extra layer of security.

```php
// Generating a random salt and hashing the password with the salt
$salt = random_bytes(16);
$password = password_hash($_POST['password'] . $salt, PASSWORD_DEFAULT);
```

Issue: Not implementing proper user authentication mechanisms can lead to unauthorized access to sensitive information. Always verify user credentials against the stored hashed password during login.

```php
// Verifying user credentials during login
if(password_verify($_POST['password'], $hashed_password)) {
    // Authentication successful
} else {
    // Authentication failed
}