# 🔑 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. ---