🚀 Day 34 of My MERN Stack Journey – Session-Based Authentication Practice Backend ✔ Database ✔ Sessions ✔ Authentication Logic ✔ Today I worked on a personal practice & revision project to better understand Session-based Authentication in Express.js. The goal of this project was not building a full product but strengthening my understanding of how login systems actually manage user sessions on the server. 📌 What I Practiced I created a simple authentication flow using Express Sessions and MongoDB where users can: ✔ Sign up and create an account ✔ Log in using contact number and password ✔ Generate a random session token after login ✔ Store that token in MongoDB + Express session ✔ Access a protected profile route only if authenticated This project helped me revise and reinforce session-based authentication concepts. ⚙️ Tech Stack ✔ Node.js ✔ Express.js ✔ MongoDB ✔ Mongoose ✔ EJS ✔ Express Session 🧠 Concepts I Focused On ✅ Session-Based Authentication Instead of JWT, this system uses server-side sessions to track logged-in users. When a user logs in: • Server generates a random token • Token stored in database • Same token stored in session req.session.token = token; 📌 Concept: Server keeps track of user identity ✅ Random Token Generation I created a custom function to generate random authentication tokens. This helped me understand how session identifiers work internally. ✅ Protected Routes Before accessing /profile, the server checks if the session token matches a user in the database. const user = await User.findOne({ token: req.session.token }); 📌 Concept: Authorization using session validation 📝 Key Learnings from This Practice 🔹 How session-based authentication works internally 🔹 How servers maintain login state using sessions 🔹 How session tokens link database users with active sessions 🔹 Clear understanding of Sessions vs JWT authentication 🔹 How protected routes verify user identity 🎯 Growth Reflection This project was mainly a revision exercise to strengthen my understanding of authentication systems. Over the last few days I practiced: ✔ Random token authentication ✔ Session-based authentication ✔ JWT authentication Now I can clearly understand how different authentication systems work under the hood. 🚀 Practice Code GitHub Repository: https://lnkd.in/dUK2Z5HZ #MERNStack #NodeJS #ExpressJS #MongoDB #Authentication #Sessions #BackendDevelopment #JavaScript #LearningInPublic
MERN Stack Session-Based Authentication Practice
More Relevant Posts
-
🚀 Day 35 of My MERN Stack Journey – Cookie-Based Authentication Practice Backend ✔ Database ✔ Cookies ✔ Authentication Logic ✔ Today I practiced Cookie-based authentication to better understand how servers maintain login state using cookies and database tokens. This was a personal practice & revision project focused on strengthening my understanding of how cookies work in authentication systems. 📌 What I Practiced I built a small authentication flow where users can: ✔ Sign up and create an account ✔ Log in using contact number and password ✔ Generate a random authentication token ✔ Store the token in cookies and MongoDB ✔ Access a protected profile route only if the token is valid This helped me clearly understand how cookies help identify logged-in users. ⚙️ Tech Stack ✔ Node.js ✔ Express.js ✔ MongoDB ✔ Mongoose ✔ EJS ✔ Cookie Parser 🧠 Concepts I Focused On ✅ Cookie-Based Authentication When a user logs in: • Server generates a random token • Token stored in MongoDB • Token also stored in browser cookies res.cookie("token", token, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000, }); 📌 Concept: Client stores identity token inside cookies ✅ Token Validation When a user tries to access /profile: • Server reads the cookie • Searches the token in MongoDB • Grants access if token matches a user const validateToken = await User.findOne({ token: req.cookies.token }); 📌 Concept: Authenticating users using stored tokens ✅ Random Token Generation I used a custom function to generate random authentication tokens to simulate how login identifiers work internally. 📌 Concept: Unique tokens for identifying logged-in users 📝 Key Learnings from This Practice 🔹 How cookies store authentication tokens 🔹 How servers read cookies using cookie-parser 🔹 How authentication tokens connect browser and database 🔹 How protected routes validate login status 🔹 Clear understanding of Cookies vs Sessions vs JWT 🎯 Growth Reflection Over the last few days I practiced three major authentication approaches: ✔ Cookie-based authentication ✔ Session-based authentication ✔ JWT authentication These practice projects helped me understand how login systems actually work behind the scenes in real applications. 🚀 Practice Code GitHub Repository: https://lnkd.in/dYHAirDg #MERNStack #NodeJS #ExpressJS #MongoDB #Authentication #Cookies #BackendDevelopment #JavaScript #LearningInPublic
To view or add a comment, sign in
-
-
𝗧𝗵𝗲 𝗥𝗶𝗴𝗵𝗍 𝗧𝗲𝗰𝗵 𝗦𝘁𝗮𝗰𝗸 𝗙𝗼𝗿 𝗬𝗼𝘂𝗿 𝗪𝗲𝗯 𝗔𝗽𝗽 Your tech stack can make or break your web application. It affects how fast you build, how well your app performs, and how easily it scales. There is no singlebest tech stack for every project. The right choice depends on what you're building, your team's expertise, and your long-term goals. A tech stack is the combination of technologies used to build and run a web application. It includes: - Frontend: The user interface users interact with - Backend: Processes data, handles requests, and powers application logic - Database: Stores and organizes application data - Tools: Ensure your application runs smoothly in production Popular tech stacks include: - MERN Stack: MongoDB, Express.js, React, Node.js - MEAN Stack: MongoDB, Express.js, Angular, Node.js - LAMP Stack: Linux, Apache, MySQL, PHP - JAMstack: JavaScript, APIs, Markup - Django + React Stack: Django, React, PostgreSQL - Serverless Stack: AWS Lambda, API Gateway, DynamoDB When choosing a tech stack, consider: - Your project needs - Scalability - Time to market - Budget - Team expertise The best tech stack aligns with your project goals, scales with your growth, and supports your team's capabilities. Evaluate your needs and set a strong foundation for long-term success. Source: https://lnkd.in/gei_BGhG
To view or add a comment, sign in
-
✂️ #Trimrr – MERN Stack URL Shortener Built a responsive #URL Shortener & Analytics platform using the MERN stack that allows users to create short links, generate QR codes, and track link performance in real time. actually, URL will not much short 😅 because of I deploy in render my backend so in frontend set those backend routes api , but its workable. 🔴See LIVE: https://lnkd.in/gXaKGANx #GitHub 📂Backend: https://lnkd.in/gVD__2GD 📂Frontend: https://lnkd.in/gY32A4fk 🔗 Key Features • User authentication with JWT • Secure password hashing using bcrypt • Generate short URLs instantly • QR code generation for each shortened link • Real-time click analytics (device & usage insights) • Extract webpage titles automatically • Clean React + Vite frontend interface • Scalable Node.js & Express backend with MongoDB ⚙️ Tech Stack React • Vite • Node.js • Express.js • MongoDB • Mongoose • JWT • Bcrypt • Cheerio • CORS This project helped me strengthen my understanding of full-stack development, API architecture, authentication systems, and real-time analytics implementation. Excited to continue building scalable and practical web applications. 🚀 #MERNStack #FullStackDevelopment #WebDevelopment #NodeJS #ReactJS #MongoDB #ExpressJS #JavaScript #SoftwareDevelopment #OpenToWork #CodingProjects #sheriyanscodingschool #responsive #mongodbcompass
To view or add a comment, sign in
-
𝗧𝗵𝗲 𝗥𝗶𝗴𝗵𝗍 𝗧𝗲𝗰𝗵 𝗦𝘁𝗮𝗰𝗸 𝗙𝗼𝗿 𝗬𝗼𝘂𝗿 𝗪𝗲𝗯 𝗔𝗽𝗽 Your tech stack can make or break your web application. It affects how fast you build, how well your app performs, and how easily it scales. There is no singlebest tech stack for every project. The right choice depends on what you're building, your team's expertise, and your long-term goals. A tech stack is a combination of technologies used to build and run a web application. It includes: - Frontend: user interface users interact with - Backend: processes data, handles requests, and powers application logic - Database: stores and organizes application data Popular tech stacks include: - MERN Stack: MongoDB, Express.js, React, Node.js - MEAN Stack: MongoDB, Express.js, Angular, Node.js - LAMP Stack: Linux, Apache, MySQL, PHP - JAMstack: JavaScript, APIs, Markup - Django + React Stack: Django, React, PostgreSQL - Serverless Stack: AWS Lambda, API Gateway, DynamoDB When choosing a tech stack, consider: - Your project's needs - Scalability - Time to market - Budget - Team expertise The best tech stack aligns with your project goals, scales with your growth, and supports your team's capabilities. Source: https://lnkd.in/gYNdvCpe
To view or add a comment, sign in
-
🚀 Excited to Share My MERN Stack Project! I’ve built a full-stack web application focused on empowering farmers by enabling direct product management—without any third-party involvement. 🌾 Project Overview This platform allows farmers to register, log in securely, and manage their agricultural products efficiently. The goal is to provide a simple and transparent system where farmers can showcase and update their produce details. 💡 Key Features 🔐 User Authentication – Secure registration and login system 📦 Product Management – Farmers can add, update, and delete product details 📊 Dashboard – A dedicated dashboard to manage products easily 🔍 Search Functionality – Quickly find products based on requirements 💾 Database Integration – All data is stored and managed using MongoDB ⚡ Real-Time Updates – Changes are instantly reflected in the database 🛠️ Tech Stack • MongoDB • Express.js • React.js • Node.js 🌟 What I Learned Implementing full CRUD operations Designing RESTful APIs Managing state and frontend-backend integration Handling real-world use cases with database updates This project strengthened my understanding of full-stack development and solving real-world problems using technology. I’m excited to keep building and improving! 🚀 #MERN #WebDevelopment #FullStackDeveloper #MongoDB #ReactJS #NodeJS #ExpressJS #Projects #LearningJourney
To view or add a comment, sign in
-
🚀 Built a Full Stack Authentication System from scratch Excited to share my latest project — a modern Login & Registration system with a clean dashboard built using: ⚛️ React.js (Frontend) ⚡ FastAPI (Backend) 🍃 MongoDB (Database) ✨ Key Features: 🔐 Secure Authentication (Login/Register) 🎯 Clean & Responsive UI ⚡ Fast & Efficient API handling 📊 Simple Dashboard This project helped me gain hands-on experience in full stack development, API integration, and database management. 📽️ Check out the demo video below! Would love your feedback 🙌 #FullStackDeveloper #ReactJS #FastAPI #MongoDB #WebDevelopment #SoftwareDeveloper #OpenToWork #TechProjects #DeveloperJourne Prabhat Kumar Singh Riya Dubey A1 Training Institute - Build India With Code & AI Python React JavaScript Developer MongoDB
To view or add a comment, sign in
-
🧰 5 Backend Practices I Wish I Knew Earlier (MERN) If you're working with Node.js + MongoDB… These will save you months of struggle 👇 1. Don’t trust default queries I used to write: 👉 find() → send data Now I always ask: • Do I need all fields? • Can I limit results? • Is this query indexed? 2. Indexing is NOT optional If your API feels slow… This is probably the reason. 👉 A single index can reduce seconds → milliseconds ⚡ 3. Avoid multiple DB calls ❌ Bad: Loop → DB call → Loop → DB call ✅ Better: Use aggregation pipeline 4. Always structure your backend Stop mixing everything in controller. 👉 Follow: Controller → Service → DB layer Your future self will thank you. 5. Handle errors properly Don’t just: 👉 try/catch → console.log Instead: • Send meaningful responses • Use proper status codes • Log errors for debugging 💡 Bonus lesson: Backend is not about writing more code It’s about writing smarter code 🚀 I’m currently focusing on: • Clean backend architecture • Performance optimization • Scalable API design If you're a MERN developer… Start applying these today 👇 You’ll see the difference in weeks. Let’s connect & grow together 🤝 #MERN #BackendDevelopment #NodeJS #MongoDB #SoftwareEngineering #BestPractices #Developers #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Just Optimized My MERN Stack Project Backend & Learned Some Powerful Concepts! Over the past few days, I worked on improving the performance, scalability, and overall code quality of my Admin Dashboard . Here’s what I implemented and learned 👇 💡 Key Optimizations & Improvements ⚡ Optimized API Performance Reduced unnecessary database calls Used parallel queries with Promise.all() Improved response time significantly ⚡ Faster MongoDB Queries Used .lean() to return plain JS objects instead of heavy Mongoose documents Implemented .select() to avoid sending unnecessary data (like passwords) ⚡ Efficient Data Fetching Replaced full data fetch with: 👉 sort({ date: -1 }).limit(5) for latest records Reduced load on server + faster UI ⚡ Clean Authentication System (JWT) Fixed token structure (used object instead of string) Improved middleware validation logic Solved real-world 403 / Unauthorized errors ⚡ Better State Management (React) Used useCallback to prevent unnecessary re-renders Used useMemo for optimized list rendering Implemented Optimistic UI updates for better UX ⚡ API Structure Improvements Clean separation of controllers, routes, middleware Reusable axios config for cleaner frontend code ⚡ Real-world Bug Fixing 🔥 Fixed 403 (Forbidden) errors Fixed 404 route issues Fixed token mismatch & header issues Debugged full frontend ↔ backend flow 🧠 What I Learned ✔️ Performance optimization is not just about speed, it's about smart data handling ✔️ Small changes like .lean() and limit() make BIG differences ✔️ Authentication bugs are very common but teach the most ✔️ Clean code = scalable code ✔️ Debugging real projects > watching tutorials 🔥 This project helped me move from “just coding” to thinking like a real developer. If you're a fresher like me — start building, break things, fix them… that’s where real learning happens 💯 #MERN #WebDevelopment #ReactJS #NodeJS #MongoDB #FullStackDeveloper #LearningInPublic #BackendDevelopment #JavaScript #CodingJourney
To view or add a comment, sign in
-
𝗠𝗘𝗥𝗡 𝗦𝘁𝗮𝗰𝗸 𝗖𝗵𝗲𝗮𝘁 𝗦𝗵𝗲𝗲𝘁 MERN is a popular JavaScript stack for building modern web applications. It includes MongoDB, Express.js, React, and Node.js. You can use this cheat sheet to quickly understand the MERN Stack. It covers the core concepts for beginners and developers. - MongoDB: Database - Express.js: Backend framework - React: Frontend library - Node.js: Runtime environment These technologies work together to create fast and scalable web applications. A typical MERN application works like this: - Client (React) sends requests - Express + Node.js handle backend logic - MongoDB stores and retrieves data Key points for each technology: - MongoDB: Stores data in JSON-like documents, flexible schema, highly scalable - Express.js: Routing, middleware support, REST API development, easy server setup - React: Components, JSX, virtual DOM, hooks - Node.js: Event-driven architecture, non-blocking I/O, high performance, large ecosystem You can use MERN for: - Full stack web applications - SaaS platforms - Startup products - Real-time applications - Single Page Applications Source: https://lnkd.in/ghG3yPRE Optional learning community: https://lnkd.in/gk4kXzaw
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development