login-css / readme.md
Gagan0141's picture
Upload 7 files
2caefcd verified
# πŸ”‘ Flask Login System with SQLite
A **beginner-friendly** login & signup system using **Flask** and **SQLite**.
This project demonstrates:
- βœ… User Signup (create a new account)
- βœ… User Login (check credentials)
- βœ… Session Management (keep users logged in)
- βœ… Cookies (store "last visit" info)
- βœ… "Remember Me" option (stay logged in even after closing browser)
---
## πŸ“‚ Project Structure
```
/project-folder
│── app.py # Main Flask application
│── users.db # SQLite database (auto-created)
│── templates/
β”‚ β”œβ”€β”€ home.html # Home page (only for logged-in users)
β”‚ β”œβ”€β”€ login.html # Login form
β”‚ └── signup.html # Signup form
````
---
## ⚑ Installation & Setup
### 1️⃣ Clone or Download
```bash
git clone https://github.com/yourusername/flask-login-system.git
cd flask-login-system
````
### 2️⃣ Create Virtual Environment (recommended)
```bash
python -m venv venv
source venv/bin/activate # On Mac/Linux
venv\Scripts\activate # On Windows
```
### 3️⃣ Install Dependencies
```bash
pip install flask
```
### 4️⃣ Run the App
```bash
python app.py
```
Flask will start at:
πŸ‘‰ [http://127.0.0.1:5000/](http://127.0.0.1:5000/)
---
## πŸ–₯️ Usage
1. Open `http://127.0.0.1:5000/signup`
* Create a new account.
2. Go to `http://127.0.0.1:5000/login`
* Enter username & password.
* Tick **Remember Me** if you want to stay logged in after closing browser.
3. After login β†’ you’ll be redirected to **Home Page**.
* It will also show your **last visit info** stored in cookies.
4. To logout β†’ go to `http://127.0.0.1:5000/logout`.
---
## πŸͺ How It Works
* **Sessions**
* Store who is logged in (`session["username"]`).
* By default, session ends when browser is closed.
* If "Remember Me" is checked β†’ session lasts **7 days**.
* **Cookies**
* Store a `last_visit` message.
* If "Remember Me" is checked β†’ cookie also lasts **7 days**.
* Otherwise, cookie disappears when browser closes.
---
## ⚠️ Security Notes (for teaching only!)
* Passwords are stored in **plain text** in this demo (❌ not secure).
* In real applications β†’ **always hash passwords** using libraries like `werkzeug.security` or `bcrypt`.
---
## ✨ Future Improvements
* Add **password hashing** for security
* Add **email verification / password reset**
* Use **Flask-Login** for better authentication management
---
## πŸ‘¨β€πŸ’» Author
Created as a **teaching project for extreme beginners** learning Flask, Sessions, and Cookies.
---