This repository provides an example of how to handle forms, sessions, and cookies in an Express.js application. Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
- Form Handling: Learn how to process and validate form data submitted via HTTP POST requests.
- Sessions: Understand how to implement session management to maintain user state across different requests.
- Cookies: Learn how to set, retrieve, and manage cookies for client-side state management.
- Authentication: Example of user authentication using sessions and cookies.
- Security: Implement best practices for securing session data and cookies.
- Node.js installed on your machine.
- Clone the repository:
git clone https://github.com/likhithkp/form-handling-sessions-cookies.git
- Navigate to the project directory:
cd form-handling-sessions-cookies
- Install the dependencies:
yarn
- Start the server:
yarn local
- Open your browser and navigate to
http://localhost:3001
.
GET /login
- Login formPOST /login
- Handle login form submissionGET /register
- Registration formPOST /register
- Handle registration form submissionGET /dashboard
- User dashboard (protected route)GET /logout
- Logout route
- Session management with
express-session
- Cookie management with
cookie-parser
- Form data parsing with
body-parser
Feel free to fork this repository, make improvements, and submit pull requests. Contributions are welcome!
This project is licensed under the MIT License.