Issue 4: Develop a Login Form and Implement Session Management
Description:
The objective of this task is to create a login feature that allows users to authenticate themselves and access their personal dashboard or profile. This includes building a login form, validating user credentials, implementing secure session management, and redirecting authenticated users to their respective pages.
Steps to Complete:
Design the Login Form:
Create a PHP file (e.g., login.php) within the public/ directory to serve as the login page.
The form should capture the following user credentials:
Username or Email
Password
Implement Client-Side Validation:
Use HTML5 attributes and JavaScript to perform basic client-side validation:
Ensure the username/email and password fields are not empty.
Provide feedback if fields are left empty before submission.
Handle Form Submission:
Upon form submission, process the form data in the same login.php file or another PHP script included via a POST request.
Sanitize the input data using PHP’s built-in functions to prevent SQL injection and cross-site scripting (XSS).
Issue 4: Develop a Login Form and Implement Session Management
Description:
The objective of this task is to create a login feature that allows users to authenticate themselves and access their personal dashboard or profile. This includes building a login form, validating user credentials, implementing secure session management, and redirecting authenticated users to their respective pages.
Steps to Complete:
Design the Login Form:
login.php
) within thepublic/
directory to serve as the login page.Implement Client-Side Validation:
Handle Form Submission:
login.php
file or another PHP script included via a POST request.Validate User Credentials:
users
table to find a user with the provided username or email.password_verify()
function.Implement Session Management:
session_start()
.$_SESSION['user_id']
,$_SESSION['username']
).Redirect Authenticated Users:
dashboard.php
).Secure the Session:
session_regenerate_id()
after successful login to prevent session fixation.HttpOnly
andSecure
flags.Provide Feedback and Error Handling:
Test the Login Process:
Acceptance Criteria: