What potential issue can arise when storing user data in a .dat file for a login system in PHP?

Potential issue: Storing user data in a .dat file for a login system in PHP can pose a security risk as the data is stored in plain text, making it vulnerable to unauthorized access. To solve this issue, it is recommended to encrypt the user data before storing it in the .dat file to ensure the security and confidentiality of the information.

// Encrypt user data before storing in .dat file
$userData = [
    'username' => 'example_user',
    'password' => password_hash('example_password', PASSWORD_DEFAULT),
];

$encryptedData = json_encode($userData);
file_put_contents('user_data.dat', $encryptedData);