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-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
git clone https://github.com/yourusername/flask-login-system.git
cd flask-login-systempython -m venv venv
source venv/bin/activate # On Mac/Linux
venv\Scripts\activate # On Windowspip install flaskpython app.pyFlask will start at: 👉 http://127.0.0.1:5000/
-
Open
http://127.0.0.1:5000/signup- Create a new account.
-
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.
-
After login → you’ll be redirected to Home Page.
- It will also show your last visit info stored in cookies.
-
To logout → go to
http://127.0.0.1:5000/logout.
-
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.
- Store who is logged in (
-
Cookies
- Store a
last_visitmessage. - If "Remember Me" is checked → cookie also lasts 7 days.
- Otherwise, cookie disappears when browser closes.
- Store a
- Passwords are stored in plain text in this demo (❌ not secure).
- In real applications → always hash passwords using libraries like
werkzeug.securityorbcrypt.
- Add password hashing for security
- Add email verification / password reset
- Use Flask-Login for better authentication management
Created as a teaching project for extreme beginners learning Flask, Sessions, and Cookies.